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

Why doesn't the dagger clone properly into the player when they join?

local function onCharacterAdded(character)
	if game.Workspace.Trueorno.Value >= 1 then
		local plr = game.Players:GetPlayerFromCharacter(character)
		local dagger = game.ReplicatedStorage.DaggerWood:Clone()
		dagger.Parent = plr.Backpack
	end
end

This script is supposed to clone a Wooden Dagger into the player's backpack each time they respawn, but it never does. It's only supposed to happen when the lobby doesn't exist, which is why I made the if statement. There are no errors, so I'm not sure what's wrong with it. If you know what is, please help by posting a comment or answer. Thanks.

1 answer

✓ Accepted answer

you never called the function that is why it is not running. Also, change it to this :

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
		if game.Workspace.Trueorno.Value >= 1 then
			local dagger = game.ReplicatedStorage.DaggerWood:Clone()
			dagger.Parent = plr.Backpack
		end
	end)
end

11 comments

0

I don't want it to be PlayerAdded, as Character is different. It should be whenever the player respawns, and not joining.

0

I think the problem is that it always goes through the if statement.

0

ok, let me change this then

0

ok, let me change this then

0

Edited! should work now

0

Thanks! Honestly thought it wouldn't work, but it did after fixing an error (changed the last end to end) to close the function)

0

Thanks! Honestly thought it wouldn't work, but it did after fixing an error (changed the last end to end) to close the function)

0

Thanks! Honestly thought it wouldn't work, but it did after fixing an error (changed the last end to end) to close the function)

0

Thanks! Honestly thought it wouldn't work, but it did after fixing an error (changed the last end to end) to close the function)

0

ok, glad I could help

0

Not sure why that same comment got posted 4 times :/

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