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

Players stats not shows for other players?

i am making a clicking game and i found out others cant see my/others stats i searched it and i found i need use RemoteEvent but i dont know how to use it my script is it:

local clicks = game.Players.LocalPlayer:FindFirstChild("leaderstats"):FindFirstChild("Clicks")
local rebirth = game.Players.LocalPlayer:FindFirstChild("leaderstats"):FindFirstChild("Rebirth")
local cooldown =  false

script.Parent.MouseButton1Click:Connect(function()
	if cooldown == false then
		cooldown = true
		if (rebirth.Value > 1) then
			clicks.Value = clicks.Value + (1 * rebirth.Value)
			wait(0.1)
			cooldown = false
		else
			clicks.Value = clicks.Value + 1
			wait(0.1)
			cooldown = false
		end
	end
end)

script.Parent.MouseButton1Click:Connect(function()
	if cooldown == false then
		script.Parent.Parent.Parent:WaitForChild("+thing").Visible = true	
		script.Parent.Parent.Parent:WaitForChild("+thing").Text = rebirth.Value
		wait(2)
		script.Parent.Parent.Parent:WaitForChild("+thing").Visible = false
	end
end)

1 answer

Well, here, you are just checking and increasing the values on the Client-side and not on Server-Side. Also, I recommend to use it at ServerSide and not ClientSide because firing RemoteEvents might result in exploitation.

Here, it is an example, you can replace it with your code. Also, just remove your increasing clicks code from the Localscript. The script is in ServerScriptService.

game.Players.PlayerAdded:Connect(function(plr) -- Easiet way to get a player
	repeat wait() until plr.Character -- Waits for the player's character to completely load
	local ldr = plr:WaitForChild("leaderstats") -- Gets the leaderstats folder
	local clicks = ldr:WaitForChild("Clicks")
	local rebirth = ldr:WaitForChild("Rebirth")

	local PlayerGui = plr:WaitForChild("PlayerGui") -- Gets the player gui
	local TextButton = PlayerGui.PUT_LOCATION_OF_TEXTBUTTON -- For eg : PlayerGui.ScreenGui.TextButton

	TextButton.MouseButton1CLick:Connect(function()
		clicks.Value = click.value + 1 -- This is just an eg. Replace this part with your code
	end)
end)

Lemme know if it helps!

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