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

I want to show the player the wins he has ?

Okay i have a problem. My problem is that i want to acess the points of the players. Here the code i use:

game.Players.PlayerAdded:Connect(function(plr)
	plr:Waitforchild("AllCurencies")
	local d = plr.AllCurencies.Wins.Value
	script.Parent.Text = plr.AllCurencies.Wins.Value
	plr.AllCurencies.Wins.Changed:connect(function()
		script.Parent.Text = plr.AllCurencies.Wins.Value
	end
) end)

2 comments

0

is this a LocalScript or a regular Script?

0

localsript

2 answers

✓ Accepted answer

I believe this is a local script. The thing is with the :Changed function on a local script, an exploiter can change the value and it looks like they have inf coins or whatever. How I think you could do this is setup a RemoteFunction in the ReplicatedStorage.

Local Script

local plr = game.Players.LocalPlayer
local remote = game.ReplicatedStorage.RemoteFunction
plr.AllCurencies.Wins.Changed:Connect(function()
	local wins = remote:InvokeServer()
	script.Parent.Text = wins.." wins!"
end)

Server Script

local remote = game.ReplicatedStorage.RemoteFunction
function remote.OnServerInvoke(plr)
	return plr.AllCurencies.Wins.Value
end

Something like that

I assume this code is written in a LocalScript, if it's not then I will edit it

local plr = game.Players.LocalPlayer --Gets the Player where the LocalScript is in
local wins = plr:WaitForChild("AllCurencies"):WaitForChild("Wins") -- Gets the wins

--This detects if the wins got changed
wins.Changed:Connect(function()
    --Changes the text when it detects a change
    script.Parent.Text = wins.Value
end)

1 comment

0

THX for local script!

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