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

My Script to destory a gui when player is using a keyboard is not working?

Asked by 5 years ago

So my script that destroy's a gui for mobile users isn't doing what its meant to do

local UserInputService = game:GetService("UserInputService")

if (UserInputService.KeyboardEnabled) then
script.Parent.Parent.Parent.MobilGui:Destroy()
end

1
Instead of using script.Parent.Parent.Parent place the local script as the child of MobilGui User#5423 17 — 5y

1 answer

Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

For first, you can put UserInputService.KeyboardEnabled == true is better. and put the scripts with child of GUI

and use this: script.Parent:Destroy()

In my point of view, your script is perfect just need to do these things

Here is the script:

local UserInputService = game:GetService("UserInputService")

wait()

if UserInputService.KeyboardEnabled == true then
    script.Parent.MobilGui:Destroy()
end

Hope it helped! :) Errors? tell-me on comments.

0
y do u need a wait() User#23365 30 — 5y
Ad

Answer this question