I need help with putting IntValue in the player’s character. I put this code in SeverScriptService.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local Value = Instance.new("IntValue")
Value.Name = 'Mana'
Value.Value = 100
Value.Parent = player
end)
From what you gave shared it seems to be a simple issue.
(As of writing this, I am not in Roblox Studio so you may have to check for syntax.)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local Character = player.Character or Player.CharacterAdded:Wait()
local Value = Instance.new("IntValue")
Value.Name = 'Mana'
Value.Value = 100
Value.Parent = Character
end)
When you create a new IntValue (in this case local Value = Instance.new("IntValue") ), you parent it to the player. The int value is actually in the player from the PlayerService and not the Workspace from that player.
Instead, you should reference the Character and then set the IntValue to the Character.
or you can just basically write it like that too…
(ik the problem is probably solved, but i wanted to show an alternative way for that…)
game.Players.PlayerAdded:Connect(function(player)
local Character = player.Character
local Value = Instance.new("IntValue", Character) -- Basically, second parameter becomes the parent of new instance
Value.Name = "Mana"
Value.Value = 100
end)
But just a reminder: After dying, your character will lose your mana stat. You can do this instead if you don’t want to lose it…
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
local Value = Instance.new("IntValue",Character)
Value.Name = "Mana"
Value.Value = 100
end)
end)
I’m not in the Studio too, you may need to check syntaxes