I am trying to make a game and one of my tools can't do damage and comes up this error some help
OnFireServer(Script)
Remote = script.Parent:FindFirstChild("OnDamage") Remote.OnServerEvent:Connect(function(Player,Damage,part) part.Parent:FindFirstChild("Humanoid"):TakeDamage(Damage) end)
Action(LocalScript)
Player = game.Players.LocalPlayer game.Workspace:WaitForChild(Player.Name) Stone = script.Parent Animation = game.Lighting.Animations.StoneSwing Track = Player.Character.Humanoid:LoadAnimation(Animation) animation = false Debounce = false Stone.Activated:Connect(function() if Debounce == false then Debounce = true Track:Play() touch = Stone.Handle.Touched:Connect(OnTouch) wait(0.3) animation = true wait(0.8) animation = false wait(0.2) Debounce = false end end) function OnTouch(part) if part.Parent:FindFirstChild("Humanoid") ~= nil and part.Parent.Name ~= Player.Name and animation == true and Hitted == false then Hitted = true Damage = 10 Stone.OnDamage:FireServer(Damage, part) wait(0.4) Hitted = false end end
Is my first time using this website!
Remote Events
shouldn’t be in tool(that’s how I and most devs like it). Try putting onDamage in the ReplicatedStorage
and put the damage script in the ServerScriptService
and try it like that. Then try writing at line 30 of the LocalScript
:
RS:WaitForChild(“onDamage”):FireServer(Damage, part) -- Assuming you made a variable of the ReplicatedStorage called RS
Then inside the Script
inside of the ServerScriptService
write:
local RS = game:GetService(“ReplicatedStorage”) local Remote = RS:WaitForChild(“OnDamage”) Remote.OnServerEvent:Connect(function(Player, Damage, part) part.Parent:FindFirstChild("Humanoid"):TakeDamage(Damage) end)
Or if you don’t wanna do all of this try adding a WaitForChild
instead of the FindFirstChild
at line 1 of the Script