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

What is wrong with this script?

I'm trying to make it so when a player joins the game, it clones a IntValue from the Lighting to the Player. This is the script I'm using below but it only works once on one player and fails to work on the next, what is wrong with it? Thanks.

function onPlayerEntered(newPlayer)
local iv = game.Lighting.playerstats
iv.Parent = newPlayer
iv.Clone()
end

game.Players.PlayerAdded:connect(onPlayerEntered)

1 answer

✓ Accepted answer

Your problem is that you aren't cloning the int value when you are putting it into the player

function onPlayerEntered(newPlayer)
	local iv = game.Lighting.playerstats:Clone() --You also have to use ":" when cloning
	iv.Parent = newPlayer
end

game.Players.PlayerAdded:connect(onPlayerEntered)

This would clone the value and set the variable 'iv' as the cloned int val and then parent it to 'newPlayer'

2 comments

0

Spelt 'connect' at the bottom wrong, but when corrected it worked. Cheers.

0

Wups, sorry!

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