-
What do you want to achieve? When you click, the animation will play accordingly.
-
What is the issue? The animation won’t fire and there is no errors.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Tool = script.Parent
local userInputServ = game:GetService("UserInputService")
local Event = game:GetService("ReplicatedStorage"):WaitForChild("Test")
local Animation = Tool.Animation
local Connection = nil
local lastChatMessage = nil
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {Player.Character, Tool}
Tool.Equipped:Connect(function()
Connection = userInputServ.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if not lastChatMessage or lastChatMessage == nil then print("c") return end
local ray = workspace:Raycast(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * 7.5, raycastParams)
if not ray or ray == nil then print("b") return end
Player.Character.Humanoid:LoadAnimation(Animation):Play()
if #lastChatMessage:split("|") ~= 2 then return end
Event:FireServer(ray.Instance.Parent.Name, lastChatMessage)
end
end)
end)
Tool.Unequipped:Connect(function()
if typeof(Connection) == "RBXScriptConnection" then
Connection:Disconnect()
end
end)
Player.Chatted:Connect(function(message)
lastChatMessage = message
end)```
Thanks.
AtlasType