Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Zypsoh 25
4 years ago

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!

0
i'm actually really lazy so it would be cool if you could tell which line has the error speedyfox66 237 — 4y
0
Its on OnFireServer(Script) Line 1 Zypsoh 25 — 4y
0
Stone is the name of the tool Zypsoh 25 — 4y

1 answer

Log in to vote
0
Answered by
St_vnC 330 Moderation Voter
4 years ago

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

0
MLGQuickSkopur ok the error its not showing anymore but the rock(Tool) Its not doing damage Zypsoh 25 — 4y
0
MLGQuickSkopur you have discord so i can talk better with you? Zypsoh 25 — 4y
Ad

Answer this question