My Idle animation won't stop working because my getPlayer function won't get the actual player? I'm not sure why it won't get the player!?
Serverscript in tool
local Tool = script.Parent local Remote = Tool:WaitForChild("Remote") local Handle = Tool:WaitForChild("Handle") local Mesh = Handle:WaitForChild("Mesh") local Equipping = false local Grip = nil local StraightMeshData = "http://www.roblox.com/asset/?id=193827643" local StraightGripPos = Vector3.new(0, 0, 1.5) local BentMeshData = "http://www.roblox.com/asset/?id=193827593" local BentGripPos = Vector3.new(0, 0.6, 0.5) local Bent = true local AttackAble = true local AttackRestTime = 1 local AttackVictims = {} local AttackWindow = 0.66 local AttackDamaging = false local AttackWindup = 0.1 function getPlayer() local char = script.Parent.Parent return game:GetService("Players"):GetPlayerFromCharacter(char) end function contains(t, v) for _, val in pairs(t) do if val == v then return true end end return false end function tagHuman(human) local tag = Instance.new("ObjectValue") tag.Value = getPlayer() tag.Name = "creator" tag.Parent = human game:GetService("Debris"):AddItem(tag) end function normal() if not AttackAble then return end --rest AttackAble = false delay(AttackRestTime, function() AttackAble = true end) --damage delay(AttackWindup, function() AttackVictims = {} AttackDamaging = true delay(AttackWindow, function() AttackDamaging = false end) end) Handle.Swing:Play() local t = math.random(1, 2) if t == 1 then Remote:FireClient(getPlayer(), "PlayAnimation", "Swing1") Handle.Trail.Enabled = true elseif t == 2 then Remote:FireClient(getPlayer(), "PlayAnimation", "Swing2") Handle.Trail.Enabled = true end end function onEquip() if Equipping then return end Equipping = true --animation Remote:FireClient(getPlayer(), "PlayAnimation", "Idle") Handle.Trail.Enabled = false Equipping = false end function onUnequip() if Grip then Grip:Destroy() end --animation Remote:FireClient(getPlayer(), "StopAnimation", "Idle") end function onRemote(player, func, ...) if player ~= getPlayer() then return end if func == "NormalStart" then normal() end end Tool.Equipped:connect(onEquip) Tool.Unequipped:connect(onUnequip) Remote.OnServerEvent:connect(onRemote)
I fixed this error by changing the GetPlayer() to script.Parent.