Well, if you need to add a RemoteEvent into ReplicatedStorage, under any folders if you want to for organization.
Next thing, on the client, where you go to change the value, you just need to call the method FireServer()
to basically send a message to the server saying “hey, you need to follow these instructions now. Here is the player that requested this, and any other data if they sent it.” That “other data” is typically referred to as “arguments.”
Here is how you do that:
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage:WaitForChild("RemoteEvent" --[[Change this to whatever you name your RemoteEvent. This does matter if you name the RemoteEvent something else]])
script.Parent.MouseButton1Click:Connect(function()
remoteEvent:FireServer(videomadewnt) --// You could pass whatever increase value you want through here, and it would send it to the server, but for that exact reason, I recommend against that. Exploiters can easily fire the RemoteEvent themselves and send whatever value they want. You should just be passing the object you want to change the value of so it is easier to access on the server.
Click:Play()
CounterTxt.Text = math.random(0, 100)
Yay:Play()
end)
Now on the server, you need to process this using RemoteEvent.OnServerEvent
, which is basically the server saying, “Okay, thank you, kind client. I appreciate you sending this message, now I will take your sent info and do this stuff with it.”
Here is the code you need to put into a server-sided script. Most preferably in ServerScriptService. You can name it something like “Events” for any use of RemoteEvents in the future (they are typically used a lot, along with RemoteFunctions, BindableEvents, and BindableFunctions. All documentation links can be viewed below):
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage:WaitForChild("RemoteEvent" --[Change this to whatever you name your RemoteEvent. This does matter if you name the RemoteEvent something else]])
remoteEvent.OnServerEvent(player, obj)
obj.Value.Value += 1
end)
With RemoteEvents, whenever you fire the server, the first argument is always the player. The “player” argument is required, and anything that is put there will be the player. That player argument, like said above, is the player of the client who fired the RemoteEvent.
I hope this helps, and please tell me if something doesn’t work right. I am glad to help until the situation is solved.
Documentation links: