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

repost of my leaderstat not changing pls help?

local humanoid = workspace.Dummy:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(script.Parent)

humanoid.Died:Connect(function()
	player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
	player.leaderstats.Levels.Value = player.leaderstats.Levels.Value + 1
end)

why is it not working

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player



	local coins = Instance.new("IntValue")
	coins.Name = "Levels"
	coins.Value = 0
	coins.Parent = leaderstats
end



game.Players.PlayerAdded:Connect(onPlayerJoin)

Same for coins but it's coins

4 comments

0

What type of script is the first script?

0

normal script in an r15 dummy

0

bottom is a normal script in serverscriptservice

0

Can you explain what you are trying to do

1 answer

I don't know if this will work, but I saw that you called the coins levels, so I solved it

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Value = 0
	coins.Parent = leaderstats
	
	local levels = Instance.new("IntValue")
	levels.Name = "Levels"
	levels.Value = 0
	levels.Parent = leaderstats
end



game.Players.PlayerAdded:Connect(onPlayerJoin)

And you got the character of the player, and not the player, because the leaderstats values is in the player, and not the character, so I solved it as well

local humanoid = workspace.Dummy:FindFirstChild("Humanoid")

humanoid.Died:Connect(function()
	game.Players.PlayerAdded:Connect(function(player)
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
		player.leaderstats.Levels.Value = player.leaderstats.Levels.Value + 1
	end)
end)

I can't confirm if it works because I don't have the dummy, and make sure that both of the Normal Scripts are in ServerScriptService.

1 comment

0

If you're wondering the dummy is just a normal r15 dummy

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