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

Why won't this script work?

Asked by
KenzaXI 166
9 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
local DamegeBall = Instance.new("Tool")
local Player = game.Players.LocalPlayer
local Fire = Instance.new("Fire")
DamegeBall.Parent = game.Players.LocalPlayer.Backpack
Fire.Parent = game.Players.LocalPlayer.Backpack.DamegeBall
Fire.Color = 21
Fire.SecondaryColor = 1004
function onTouch(Brick)
    if(Player ~= nil)then
        Player.Health = Player.Health - 30
    end
end
DamegeBall.Touched:connect(onTouch)

I have no Idea why it won't work. This is the first time I'm making a tool I've only made a giver before.

this script's purpose is too make a Tool which has a fire instance in it and it Damages any player it touches by 30

I've set it so the Tool's location becomes starter backpack but it won't work.

0
what is it supposed to do? Kryddan 261 — 9y
0
and is this a localscript or a normal script. And what does the output say? Kryddan 261 — 9y
0
Try replacing line 10 with Player.Character.Humanoid.Health = Player.Character.Humanoid.Health - 30 UserOnly20Characters 890 — 9y

1 answer

Log in to vote
0
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

In ROBLOX Studio, when you play a game that you are working on, if there are any errors in your script, it will show up in the Output window. Looking at those errors will help you figure out what is wrong with your script.

Output article on ROBLOX Wiki

If I go in ROBLOX Studio and add your script as a LocalScript and run it, I will get this error in the output window:

13:42:56.240 - DamegeBall is not a valid member of Backpack 13:42:56.241 - Script 'Players.Player1.Backpack.LocalScript', Line 5 13:42:56.241 - Stack End

This tells you both the line number that the error happened on, and what the error was. In your case, you never set the Name property of the new Tool that you created, so the name is still Tool. On line 5 when you try to set the Fire's parent to game.Players.LocalPlayer.Backpack.DamegeBall, you get an error because there is no item with that name in the Backpack.

Ad

Answer this question