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

GUI Script not working?

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?

2 comments

0

?

1

I'm blind and I thought I saw a spelling mistake xD

1 answer

✓ Accepted answer

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!

4 comments

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?

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.

0

I just put them into seperate scripts which seems to work now, but thanks for your help!

0

I helped :D

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