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

How come this script wont work?(Lines 12-15) wont work

This is my damage script to my fire ball tool and it works with the damage but when I try to add it so that if the Player kills another person their Exp stat in the leader board raises the damage still works but the Exp stat in leader board doesn't raise. I used the Variable PlayerName to find the name of the Player in the Players Folder so I can access the player


PlayerName = script.Parent.Parent.Parent.Name

function onDamage(Part)
	if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent.Name ~= "script.Parent.Name" then
		script.Disabled = true
		f = Instance.new("Fire", Part)
		for i = 1,25 do
			f.Size = f.Size +0.25
			Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -1
			wait(0.05)
		end
		Part.Parent.Humanoid.Sit = true
		if Part.Parent.Humanoid.Health <= 0 then
			game.Players.PlayerName.leaderstats.Exp = game.Players.PlayerName.leaderstats.Exp +1
			end
		f:remove()
		script.Parent:remove()
	end
	wait(0.025)
end

script.Parent.Touched:connect(onDamage)

2 comments

0

Look closely at line 4, what Part.Parent.Name is doing. :P

0

Try a 'humanoid.Died' connect line. It's in the tips on this website.

3 answers

Line 4, is the part possibly named script.Parent.Name? If not, remove the quotations and it should work fine. I don't see any other clear errors

1 comment

0

That is not the problem because that is just for you don't hit yourself. The lines I wanted to add in was 12-14 which gave the Player Exp if they killed a person

game.Players.LocalPlayer.leaderstats.Exp = game.Players.LocalPlayer.leaderstats.Exp +1

On line 5, you disable the script. That's why nothing happens.

1 comment

0

No the disable is to stop spamming even with the line the script works its only line 12-15

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