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

Weapon Giver Script Is Not Working? Help Please?

The code below works properly, but if the player resets or dies, they're not able to receive the weapon again even if they step on the brick. I know why it doesn't work, and that's because I'm using the PlayerAdded event. The reason I'm posting this is because I only know how to make the script this way, and I know for a fact that it's possible to make the script without using PlayerAdded. So, let's cut to the chase:

game.Players.PlayerAdded:connect(function(player)

debounce = false

game.Workspace["Sword Giver Block"].Touched:connect(function(give)
if debounce == true then return end
debounce = false
game.Lighting.ClassicSword:Clone().Parent = player.Backpack
debounce = true
end)
end)

Is anyone willing to show me how to make it without using PlayerAdded?

1 answer

✓ Accepted answer

It's simple really. Just take out line 01 and 11, then use the GetPlayerFromCharacter(character) method of Players.

debounce = false

game.Workspace["Sword Giver Block"].Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if debounce == true or player == nil then return end
	debounce = false
	game.Lighting.ClassicSword:Clone().Parent = player.Backpack
	debounce = true
end)

1 comment

0

Thank you so much!

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