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

Trying to make part visible on your body , if you are in a group, cant get script to work?

Asked by 4 years ago

I have a script ive used for GUIs that only shows on your screen if your in the group, how can I make it so that it makes a part visible on your player if your in the group? (The part loads onto the body automatically which works I just want it to be made visible if your in the group)

local player = game.Players.LocalPlayer
local groupId = 609409

while true do
    if player:IsInGroup(groupId) then
   script.Parent.SurfaceGui.Enabled = true
end
end

1 answer

Log in to vote
0
Answered by 4 years ago

Your biggest issue is the creation of an infinite loop with no delays which will crash a game/studio. An easy fix is adding a wait somewhere within the code.

local player = game.Players.LocalPlayer
local groupId = 609409

while true do
    if player:IsInGroup(groupId) then
        script.Parent.SurfaceGui.Enabled = true
        break -- stop this loop, no purpose at this point
    end
    wait(1) -- wait 1 second 
end

You are using a local script, the only person that may see this change is the script owner!

0
How do I make it a Server Side script? Moo_Blinder 18 — 4y
0
Sorry for the slow response. A server side script is the element in studio called "script". You cannot grab player via game.Players.LocalPlayer using one alphawolvess 1784 — 4y
Ad

Answer this question