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

Text Button onClicked Not Working In-game?

Asked by 6 years ago

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)
0
Are you working in a local script or normal script? Audiimo 105 — 6y
0
A RemoteEvent is needed PolyyDev 214 — 6y
0
This is a server script BunnyFilms1 297 — 6y

1 answer

Log in to vote
0
Answered by
PolyyDev 214 Moderation Voter
6 years ago

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)
0
If this works, I will explode BunnyFilms1 297 — 6y
0
IT WORKS! Hallelujah it works... I am stunned... BunnyFilms1 297 — 6y
0
The wonders of RemoteEvents PolyyDev 214 — 6y
Ad

Answer this question