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

How do i instance a intvalue?

im trying to make an rpg and for the exp i am using and intvalue and i cant seem to get it to go into the player

game.Players.PlayerAdded:connect(function() local expe = Instance.new("IntValue") expe.Parent = game.Players.LocalPlayer expe.Value = 0

end)

1 comment

0

its actually more organized than that i dont know what happened

3 answers

Remember, LocalPlayer can only be accessed by a LocalScript, and you have another error; Other then the LocalPlayer, you left out something in your PlayerAdded event; the Player, you forgot to specify the Player in the function/event, let's fix up your script;

game.Players.PlayerAdded:connect(function(plr) --'plr' here will specify the Player that has joined the server/game
local expe = Instance.new("IntValue") --Correct; this will create a new Instance [in this case, it will create the IntValue]
expe.Parent = plr --This will set the Parent of 'expe' to 'plr' [the Player]
expe.Value = 0 --This will set 'expe''s Value to 0
end) --This ends the code block for the event/function

Hope this helped!

	game.Players.PlayerAdded:connect(function() local expe = Instance.new("IntValue") expe.Parent = 					game.Players.LocalPlayer expe.Value = 0

end)

To organize a Script, you need to put Code Blocks in, or press the Lua button before answering or making a post, the one in a blue bubble.

As for your question.. it looks right to me, but I can't be sure.

it still didnt work, this is the exact code i used in a regular script

game.Workspace.Players.PlayerAdded:connect(function(plr)
	local expe = Instance.new("IntValue")
	expe.Parent = plr
	expe.Value = 0
end)

1 comment

0

Remove ".Workspace"

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