-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFEPlayAnimation
More file actions
71 lines (59 loc) · 2.01 KB
/
Copy pathFEPlayAnimation
File metadata and controls
71 lines (59 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--// GUI setup
local ScreenGui = Instance.new("ScreenGui", game.Players.LocalPlayer:WaitForChild("PlayerGui"))
local Frame = Instance.new("Frame", ScreenGui)
local TextBox = Instance.new("TextBox", Frame)
local Button = Instance.new("TextButton", Frame)
local UICorner = Instance.new("UICorner", Frame)
ScreenGui.Name = "AnimGUI"
Frame.Size = UDim2.new(0, 250, 0, 140)
Frame.Position = UDim2.new(0.4, 0, 0.4, 0)
Frame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
UICorner.CornerRadius = UDim.new(0, 8)
TextBox.Size = UDim2.new(0.8, 0, 0.3, 0)
TextBox.Position = UDim2.new(0.1, 0, 0.15, 0)
TextBox.PlaceholderText = "Nhập Animation ID"
TextBox.Text = ""
TextBox.TextColor3 = Color3.fromRGB(255, 255, 255)
TextBox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
Button.Size = UDim2.new(0.8, 0, 0.3, 0)
Button.Position = UDim2.new(0.1, 0, 0.6, 0)
Button.Text = "Play Animation"
Button.TextColor3 = Color3.fromRGB(255, 255, 255)
Button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
--// Make draggable
Frame.Active = true
Frame.Draggable = true
--// Logic
local Players = game:GetService("Players")
local lp = Players.LocalPlayer
local function stopAllAnimations(char)
local humanoid = char:FindFirstChildOfClass("Humanoid")
if humanoid then
-- Stop all playing tracks
for _, track in ipairs(humanoid:GetPlayingAnimationTracks()) do
track:Stop()
end
-- Remove Animate script if exists (prevents auto idle/walk/jump)
local animScript = char:FindFirstChild("Animate")
if animScript then
animScript:Destroy()
end
end
end
local function playCustomAnimation(id)
local char = lp.Character or lp.CharacterAdded:Wait()
local humanoid = char:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
stopAllAnimations(char)
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://" .. id
local track = humanoid:LoadAnimation(anim)
track.Looped = true
track:Play()
end
Button.MouseButton1Click:Connect(function()
local animId = TextBox.Text
if animId ~= "" then
playCustomAnimation(animId)
end
end)