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

Why is my script not working when clicked, and when Touched works?

Asked by
Peeshavee 226 Moderation Voter
7 years ago

So, basically, I'm making my own shop. Just starting from the basics for now. My shop works when I use a Touched event, but when I use a TextButton, NOTHING works. Here's my script:

local part = game.Workspace.surface
local db = true



function check(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    local character = game.Players:GetPlayerFromCharacter(hit.Parent)
        if human then

            db = false

            if character.leaderstats.Money.Value >= 5 then

                character.leaderstats.Money.Value = character.leaderstats.Money.Value - 5

                game.Lighting.RocketLauncher:Clone().Parent = character.Backpack

                db = true

            else
                print("You need more money!")

            end
        end
    end


part.SurfaceGui.TextButton.MouseClick:connect(check)

All help is appreciated!

1
.MouseClick is an event for ClickDetectors, not TextButtons. DepressionSensei 315 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Try changing from

part.SurfaceGui.TextButton.MouseClick:connect(check) 

to

part.SurfaceGui.TextButton.MouseButton1Click:connect(check)
0
No difference. :P Peeshavee 226 — 7y
0
There's one of the many problems. User#11440 120 — 7y
Ad

Answer this question