When I click with a tool equipped I want an animation to play but it will not work.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage.Remotes:WaitForChild("Basic")
remoteEvent.OnServerEvent:Connect(function(player)
print(player.Character.Name)
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://17397338573"
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage.Remotes:WaitForChild("Basic")
remoteEvent.OnServerEvent:Connect(function(player)
print(player.Character.Name)
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid") or player.CharacterAdded:Wait()
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://17397338573"
if humanoid then
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
end
end)
local module = {}
local replicatedStorage = game:GetService("ReplicatedStorage")
function module.Lift()
replicatedStorage.Remotes.Lift:FireServer()
replicatedStorage.Remotes.Basic:FireServer()
end
return module
the local script is
local module = require(script.Parent:WaitForChild("ModuleScript"))
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function()
module.Lift()
end)
Try firing the remote events like this (in the LocalScript). Since your project was created a while ago (if that was what you said), some things may break overtime.
local replicatedStorage = game:GetService("ReplicatedStorage")
script.Parent.Activated:Connect(function()
replicatedStorage.Remotes.Lift:FireServer()
replicatedStorage.Remotes.Basic:FireServer()
end)
local replicatedStorage = game:GetService("ReplicatedStorage")
local parent = script.Parent
local Basic, Lift = replicatedStorage.Remotes:WaitForChild("Basic"), replicatedStorage.Remotes:WaitForChild("Lift")
local function FireEvents()
Lift:FireServer()
Basic:FireServer()
end
parent.Activated:Connect(FireEvents)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage.Remotes:WaitForChild("Basic")
remoteEvent.OnServerEvent:Connect(function(player)
print(player.Character.Name)
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
local animation = replicatedStorage.Animations.Animation
local animationTrack = humanoid.Animator:LoadAnimation()
animationTrack:Play()
end)