So I have this and I am working with FE and in studio, this works but ingame, it doesnt work. This is in the PlayerGui. Why does this not work in-game? (The output log and server log get no output)
local function onClicked(player) script.Parent.Parent.leaderstats.Money.Value = script.Parent.Parent.leaderstats.Money.Value +10 end script.Parent.HomePurchase.Frame.Price.MouseButton1Click:Connect(onClicked)
A RemoteEvent
is needed in this script.
Put a local script where you want in the gui, in a TextButton
in this example. In the localscript should be:
local event = game:GetService("ReplicatedStorage").Event local function onClicked() event:FireServer(10) end script.Parent.MouseButton1Click:Connect(onClicked)
The following script should be a Server Script
in ServerScriptService
local event = game:GetService("ReplicatedStorage").Event local function onEvent(player,money) player.leaderstats.Money.Value = player.leaderstats.Money.Value + money -- Assuming it's leadersats in the player end event.OnServerEvent:Connect(onEvent)