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

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

Asked by 9 years ago
-- 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.

0
'onclick' is not a valid event, consider changing to 'MouseClick'. TheeDeathCaster 2368 — 9y
0
I'll try that Champion121212 22 — 9y
0
When I click it, I get the output "LocalPlayer is not a valid member of DataModel" now Champion121212 22 — 9y
1
Line 8 [game.LocalPlayer.StarterGui? Don't you mean game.Players.PlayerGui?]. TheeDeathCaster 2368 — 9y
View all comments (4 more)
0
Still nothing. Champion121212 22 — 9y
1
He meant "game.Players.LocalPlayer.PlayerGui." Redbullusa 1580 — 9y
0
All of you forgot the the Player is defined as a parameter within the connection. Shawnyg 4330 — 9y
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 Champion121212 22 — 9y

Locked by Shawnyg, EzraNehemiah_TF2, and adark

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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)
0
As always, good work and thanks! Champion121212 22 — 9y
0
No problem. Glad I could always answer your questions. Shawnyg 4330 — 9y
Ad