How to make a local script and a script communicate with eachother?

I have a leaderstats script, Which is a normal script, In workspace.

I then have a local script which is in startergui, In a button. then I need them both to communicate to each other.

Like this:
When button clicked: Money.value = 100

The first part is the local script, The second is the norm script.

u can use remote event
https://developer.roblox.com/en-us/api-reference/class/RemoteEvent

Create a RemoteEvent in ReplicatedStorage

Local Script inside your button

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.RemoteEvent
local Button = script.Parent
local Amount = 100 -- Change if you want

Button.MouseButton1Click:Connect(function()
    Event:FireServer(Amount)
end)

Script inside ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.RemoteEvent

Event.OnServerEvent:Connect(function(Plr, Amount)
    Plr.leaderstats.Money.Value = Amount
end)
1 Like

Remoteevents are epic. Use it as it’s designed for that

You would need to use remote events to send the information that you have clicked a button from a client and then that information will pass through the remote event and be sent to the server, so you can do any changes in the server script.