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

Whats the best way to fix my on win script? Its not awarding stuff to the leaderboard!

Does anyone know?

amnt = 1 --how much you get for it

return function(winner)
	function onTouched(part)
		local h = part.Parent:findFirstChild("Humanoid")
		if (h~=nil) then
			local thisplr = game.Players:findFirstChild(h.Parent.Name)
		if (thisplr~=nil) then
			local stats = thisplr:findFirstChild("leaderstats")
		if (stats~=nil) then
			local score = stats:findFirstChild("Wins")
		if (score~=nil) then
			score.Value = score.Value + amnt
				end
			end
		end
	end
end

end




1 comment

0

is it a local script? FE makes local scripts unable to change values

1 answer

I suggest putting a server script in the win part that contains this script:

local amnt = 1

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
		local plrName = hit.Parent.Name
		local plr = game.Players:FindFirstChild(""..plrName)
		if plr ~= nil then
			if plr.leaderstats ~= nil then
				local stat = plr.leaderstats.Wins
				stat.Value = stat.Value + amnt
			end
		end
	end
end)

see if this works

2 comments

0

keywords: server script, win part

0

this will make them earn a ton of win points tho so do try and figure out a way to make it only happen once like for example make debounce true until they restart or something like that

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