Hello, I am having some trouble with a saw script:
When I reset character I get this error in this line
Full script:
local tool = script.Parent
local plr = game.Players.LocalPlayer
local anim = script.Parent:WaitForChild("CutAnim")
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local hey = character:WaitForChild("Humanoid"):LoadAnimation(anim)
local ui = plr.PlayerGui:WaitForChild("SawUI") or script.Parent.SawUI
local text = ui.TextLabel
local mouse = plr:GetMouse()
local event = script.Parent.Event.Value
local particleevent = script.Parent.ParticleEvent.Value
local things = tool.Handle:GetChildren()
local sound = script.Parent.Sound
tool.Activated:Connect(function()
if mouse.Target.Parent.Name == "Bdoor" and mouse.Target.Anchored == true then
local hi = mouse.Target.Parent
print("Good thing")
if mouse.Target.Parent.Name == "Bdoor" and (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude > 1.5 and (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude < 4 then
hey:Play()
sound:Play()
local on = true
particleevent:FireServer(things, on)
wait(4)
local parts = hi:GetDescendants()
local on = false
particleevent:FireServer(things, on)
hey:Stop()
event:FireServer(parts)
elseif (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude < 1.5 then
text.Text = "You are too close"
print("Too close")
wait(1.5)
text.Text = ""
elseif (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude > 4 then
text.Text = "You are too far"
print("Too far")
wait(1.5)
text.Text = ""
else
print("This is broken")
end
else
print("Bad thing")
text.Text = "You cannot break this"
wait(1.5)
text.Text = ""
end
end)
tool.Deactivated:Connect(function()
hey:Stop()
sound:Stop()
local on = false
particleevent:FireServer(things, on)
end)
local hey = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(anim) or game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild"Humanoid":LoadAnimation(anim)
local player = game.Players.LocalPlayer
player.CharacterAdded:Connect(function(character)
local hey = character:WaitForChild("Humanoid"):LoadAnimation(Anim)
--rest of the code
end)
local tool = script.Parent
local plr = game.Players.LocalPlayer
local anim = script.Parent:WaitForChild("CutAnim")
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
plr.CharacterAdded:Connect(function(char)
hey = char:WaitForChild("Humanoid"):LoadAnimation(anim)
end)
local ui = plr.PlayerGui:WaitForChild("SawUI") or script.Parent.SawUI
local text = ui.TextLabel
local mouse = plr:GetMouse()
local event = script.Parent.Event.Value
local particleevent = script.Parent.ParticleEvent.Value
local things = tool.Handle:GetChildren()
local sound = script.Parent.Sound
tool.Activated:Connect(function()
if mouse.Target.Parent.Name == "Bdoor" and mouse.Target.Anchored == true then
local hi = mouse.Target.Parent
print("Good thing")
if mouse.Target.Parent.Name == "Bdoor" and (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude > 1.5 and (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude < 4 then
hey:Play()
sound:Play()
local on = true
particleevent:FireServer(things, on)
wait(4)
local parts = hi:GetDescendants()
local on = false
particleevent:FireServer(things, on)
hey:Stop()
event:FireServer(parts)
elseif (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude < 1.5 then
text.Text = "You are too close"
print("Too close")
wait(1.5)
text.Text = ""
elseif (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude > 4 then
text.Text = "You are too far"
print("Too far")
wait(1.5)
text.Text = ""
else
print("This is broken")
end
else
print("Bad thing")
text.Text = "You cannot break this"
wait(1.5)
text.Text = ""
end
end)
tool.Deactivated:Connect(function()
hey:Stop()
sound:Stop()
local on = false
particleevent:FireServer(things, on)
end)
local tool = script.Parent
local plr = game.Players.LocalPlayer
local anim = script.Parent:WaitForChild("CutAnim")
local ui = plr.PlayerGui:WaitForChild("SawUI") or script.Parent.SawUI
local text = ui.TextLabel
local mouse = plr:GetMouse()
local event = script.Parent.Event.Value
local particleevent = script.Parent.ParticleEvent.Value
local things = tool.Handle:GetChildren()
local sound = script.Parent.Sound
plr.CharacterAdded:Connect(function(character)
local hey = character:WaitForChild("Humanoid"):LoadAnimation(anim)
tool.Activated:Connect(function()
if mouse.Target.Parent.Name == "Bdoor" and mouse.Target.Anchored == true then
local hi = mouse.Target.Parent
print("Good thing")
if mouse.Target.Parent.Name == "Bdoor" and (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude > 1.5 and (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude < 4 then
hey:Play()
sound:Play()
local on = true
particleevent:FireServer(things, on)
wait(4)
local parts = hi:GetDescendants()
local on = false
particleevent:FireServer(things, on)
hey:Stop()
event:FireServer(parts)
elseif (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude < 1.5 then
text.Text = "You are too close"
print("Too close")
wait(1.5)
text.Text = ""
elseif (mouse.Target.Position - character.HumanoidRootPart.Position).magnitude > 4 then
text.Text = "You are too far"
print("Too far")
wait(1.5)
text.Text = ""
else
print("This is broken")
end
else
print("Bad thing")
text.Text = "You cannot break this"
wait(1.5)
text.Text = ""
end
end)
tool.Deactivated:Connect(function()
hey:Stop()
sound:Stop()
local on = false
particleevent:FireServer(things, on)
end)
end)