Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Text Button onClicked Not Working In-game?

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)

3 comments

0

Are you working in a local script or normal script?

0

A RemoteEvent is needed

0

This is a server script

1 answer

✓ Accepted answer

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)

3 comments

0

If this works, I will explode

0

IT WORKS! Hallelujah it works... I am stunned...

0

The wonders of RemoteEvents

This discussion is preserved as it was. New answers, comments, and votes are closed.