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

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

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 comment

1

.MouseClick is an event for ClickDetectors, not TextButtons.

1 answer

Try changing from

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

to

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

2 comments

0

No difference. :P

0

There's one of the many problems.

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