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

Why won't this script work?

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.

3 comments

0

what is it supposed to do?

0

and is this a localscript or a normal script. And what does the output say?

0

Try replacing line 10 with Player.Character.Humanoid.Health = Player.Character.Humanoid.Health - 30

1 answer

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.

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