Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(SOLVED)Leaderstats changer not working in normal games, only in studio?

Asked by 6 years ago
Edited 6 years ago
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent

function click()
    plr.leaderstats.Clicks.Value = plr.leaderstats.Clicks.Value + 1
end

script.Parent.MouseButton1Click:connect(click)

It's in a GUI and I've already tried script and local script and it still would do nothing.

2 answers

Log in to vote
1
Answered by 6 years ago

Put everything in a local script and use a RemoteEvent inside of ReplicatedStorage, also you can get the player by just doing

local plr = game:GetService("Players").LocalPlayer
local rs = game:GetService("ReplicatedStorage")

function click()
    rs.ClickEvent:FireServer() -- Create a RemoteEvent in ReplicatedStorage and call it ClickEvent
end

script.Parent.MouseButton1Click:connect(click)

And on a server script inside of ServerScriptService would be

local rs = game:GetService("ReplicatedStorage")

rs.ClickEvent.OnServerEvent:connect(function(player) -- Remote events always return the player
    player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value + 1
end)

If you have any questions or if this does not work please let me know.

0
Thanks! I will try that in a moment. tobylee1112 22 — 6y
0
So just trying to being clear to myself, so now I do not put functions in local scripts and put them in ServerScriptService with a server script? tobylee1112 22 — 6y
0
The functions can go in a local script, the server script can have the code I mentioned above. jackfrost178 242 — 6y
0
So can I have many of these? And will FE affect my Developer Product script? tobylee1112 22 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Im assuming your game is FE. If it is then in studio you can imagine playing the game and Server and Client are all together. Instead I reccomend doing Server testing which can be done from the same menu as test but it will say server, it will create new windows and you will be able to properly test your game out. You should also use Remote Events if that is a GUI. https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

0
Hi there, thanks. I've already tried doing that but it's still the same. I think it has to be something with FE? tobylee1112 22 — 6y
0
Because I'm not familiar with Remove Events tobylee1112 22 — 6y

Answer this question