Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

OnDamage is not a valid member of Tool (How i fix?)

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!

3 comments

0

i'm actually really lazy so it would be cool if you could tell which line has the error

0

Its on OnFireServer(Script) Line 1

0

Stone is the name of the tool

1 answer

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

2 comments

0

MLGQuickSkopur ok the error its not showing anymore but the rock(Tool) Its not doing damage

0

MLGQuickSkopur you have discord so i can talk better with you?

This discussion is preserved as it was. New answers, comments, and votes are closed.