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

GUI Script not working?

Asked by
JJ_B 250 Moderation Voter
8 years ago

I made a script that gives you a different GUI depending on the name of an object. However, the script only works if the object has the specified name, and doesn't give you any GUI if the name is different. Here is the script:

function loadscreen(Player)
    if script.Parent.Parent.Name == "TB" .. Player.Name then
    if not Player.PlayerGui:FindFirstChild("Gui") then
        local gui = script.Gui:clone()
        gui.Parent = Player.PlayerGui
    else
        if not Player.PlayerGui:FindFirstChild("nope") then
        local guin = script.nope:clone()
        guin.Parent = Player.PlayerGui
    end
    end
    end
    end

script.Parent.ClickDetector.MouseClick:connect(loadscreen)

The part of the script after the 'else' part is the part that does not work. There are no errors in the output. Please help?

0
? JJ_B 250 — 8y
1
I'm blind and I thought I saw a spelling mistake xD User#11440 120 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Try changing line two to,

if script.Parent.Parent.Name == ("TB"..Player.Name) then

It's also worth noting that while filtering enabled is on click detectors don't work like you would expect and it doesn't return Player. So in order to fix this you would need to use Romote events.

You probably don't need to change your script. Just set up a remote event to fix this problem.

Good luck!

0
Unfortunately when running the new script I was greeted by the error: "Workspace.Model.Part.Script:2: attempt to call global 'string' (a table value)" Any ideas? JJ_B 250 — 8y
0
Try capitalizing the S in string xD if that doesn't work then I edited my answer :P but like I said. I think your script is pretty much fine. You were just trying to get a player from a click detector with filtering enabled. User#11440 120 — 8y
0
I just put them into seperate scripts which seems to work now, but thanks for your help! JJ_B 250 — 8y
0
I helped :D User#11440 120 — 8y
Ad

Answer this question