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

I can't get this localscript to open a GUI?

-- setup local variables
local attendent = game.Workspace.AttendentBrick
-- when player clicks on attendent brick it will open gui if they are in group and certain rank
attendent.ClickDetector.onclicked:connect(function()
    if (game.Players.LocalPlayer:IsInGroup(555451)) then
         game.Lighting.FlightAttendentGui:Clone()
        clo = game.Lighting.FlightAttendentGui:Clone()
        clo.Parent = game.LocalPlayer.StarterGui   
    end
end)

The localscript is under the player. I want it to be when they click a brick, a gui will open up only if they are in a group. Sorry it must be bad since my main focus is building.

8 comments

0

'onclick' is not a valid event, consider changing to 'MouseClick'.

0

I'll try that

0

When I click it, I get the output "LocalPlayer is not a valid member of DataModel" now

1

Line 8 [game.LocalPlayer.StarterGui? Don't you mean game.Players.PlayerGui?].

0

Still nothing.

1

He meant "game.Players.LocalPlayer.PlayerGui."

0

All of you forgot the the Player is defined as a parameter within the connection.

0

If one of you would like to type that as an answer, I would be happy to like it and make it the solution

1 answer

✓ Accepted answer

A couple of mistakes. I put some comments for you.

-- setup local variables
local attendent = game.Workspace.AttendentBrick
-- when player clicks on attendent brick it will open gui if they are in group and certain rank
attendent.ClickDetector.MouseClick:connect(function(p) -- The proper event name is "MouseClick". The player is the one and only parameter. I have it set as "p"
    if (p:GetRankInGroup(555451) > 1) then -- Since you said a certain rank, you have to use the GetRankInGroup method. You can change the number. By default, I have it as 1, which means they're in the group.
        game.Lighting.FlightAttendentGui:clone().Parent = p.PlayerGui -- Proper descendants   
    end
end)

2 comments

0

As always, good work and thanks!

0

No problem. Glad I could always answer your questions.

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