I'm trying to print the players name but it isn't working and I can't figure out where the error is?
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent) local Active = false script.Parent.Activated:Connect(function() if Active == false then Active = true animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animation) animation:Play() animation.Stopped:Wait() print(player.Name) wait(1) Active = false end end) script.Parent.Unequipped:Connect(function() animation:Stop() end)
Nvm I figured it out. It's because the script is running before the tool gets placed inside the character. It can be solved if I change
local player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)
to
local player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent) or script.Parent.Parent.Parent