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

Gui not firing function on player input fix?

I created a keypad in ro studio and it worked fine but when I tested it in a roblox server it didn't work, just a note I am using surface GUIs and my game is filtering enabled.

script for button 1:

local text = script.Parent.Parent.Parent.Parent.screen.Gui.Top.TextLabel
local debounce = false

script.Parent.MouseButton1Down:connect(function()
	if debounce == false then
		debounce = true
		local num = script.Parent.Name
		text.Text = text.Text..num
		debounce = false
	end
end)

The script is inside a surface gui and the game is filtering enabled but when I turn filtering enabled off it works perfectly fine.

Thank you in advance

1 answer

local text = script.Parent.Parent.Parent.Parent.screen.Gui.Top.TextLabel
local debounce = false

script.Parent.MouseButton1Down:connect(function()
    if debounce == false then
        debounce = true
        local num = script.Parent.Name --This is the line I changed
        text.Text = text.Text..num
        debounce = false
    end
end)

So you did script.Parent.MouseButton1Down, so my understanding is that it is some type of button. And on the line that I indicated above, you put 'tostring(script.Parent)' which means you are trying to turn an object into a script, which isn't possible. I think you meant to put 'tostring(script.Parent.Name)', which gets the name (a string) of the object. But since you are using a name, it is already a string so no need to do 'tostring()'. Hope I helped!

3 comments

0

still didn't work

0

i added some more information on my question

0

the game is filtering enabled aswell

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