Script not working

Hello guys, I’ve tried a script that has not worked.

It only shows the animation to the server:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		script.Parent.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			if hum then
				local animation = script.Parent.Parent.Scoot
				local animator = hum.Animator
				animator:LoadAnimation(animation):Play()
				character.HumanoidRootPart.CFrame = script.Parent.Parent:WaitForChild("Teleport").CFrame
				character.Humanoid.WalkSpeed = 0
				character.Humanoid.UseJumpPower = true
				character.Humanoid.JumpPower = 0
			end
		end)
	end)
end)

Even if I try convert it to a local script, it won’t actually work.

I’ve heard of RemoteEvents but I’m not sure how to use them in this situation.

Here’s the local script I’ve tried:

local character = game.Players.LocalPlayer.Character

		script.Parent.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			if hum then
				local animation = script.Parent.Parent.Scoot
				local animator = hum.Animator
				animator:LoadAnimation(animation):Play()
				character.HumanoidRootPart.CFrame = script.Parent.Parent:WaitForChild("Teleport").CFrame
				character.Humanoid.WalkSpeed = 0
				character.Humanoid.UseJumpPower = true
				character.Humanoid.JumpPower = 0
			end
		end)

Sorry if my grammar is trash, I literally just woke up and also sorry if this is a stupid question, again, I just woke up.

1 Like

Yeah, I knew this was a stupid question, 2 hours later and I figured I need to use RemoteEvents. If any body is curious, here’s how:

Server Script:


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		script.Parent.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			if hum then
				local animation = script.Parent.Parent.Scoot
				local animator = hum.Animator
				animator:LoadAnimation(animation):Play()
				script.Parent.Transfer:FireAllClients()
				character.HumanoidRootPart.CFrame = script.Parent.Parent:WaitForChild("Teleport").CFrame
				character.Humanoid.WalkSpeed = 0
				character.Humanoid.UseJumpPower = true
				character.Humanoid.JumpPower = 0
			end
		end)
	end)
end)

Local Script:


local animation = script.Parent.Parent.Scoot

local animator = game.Players.LocalPlayer.Character.Humanoid.Animator

script.Parent.Transfer.OnClientEvent:Connect(function(animplay)

animator:LoadAnimation(animation):Play()

end)

Have you utilised remote events to fire the animation?