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

Group script does not do its function, why?

So I have 2 scripts which when you click a button, the script disables another script.

Script 1 (Checker)

local function Click(Player)
	if Player.IsInGroup(group.Value) then
		script.Parent.Script.Disabled = false	
	else
    script.Parent.Script.Disabled = true
end

script.Parent.Control1.SurfaceGui.TextButton.MouseButton1Click:connect(click)

Script 2 (Door Script)

function click()
if(script.Parent.Status.Value)=="Closed" then
script.Parent.Status.Value="Opening"
movements=37
speed=0.2
for i=1,movements do
wait(0.01)
script.Parent.PLT.CFrame=script.Parent.PLT.CFrame + Vector3.new(0,speed,0);
end
script.Parent.Status.Value="Open"

elseif(script.Parent.Status.Value)=="Open" then
script.Parent.Status.Value="Closing"
movements=37
speed=0.2
for i=1,movements do
wait(0.01)
script.Parent.PLT.CFrame = script.Parent.PLT.CFrame + Vector3.new(0,-speed,0);
end
script.Parent.Status.Value="Closed"


end
end
script.Parent.Control1.SurfaceGui.TextButton.MouseButton1Click:connect(click)

2 answers

✓ Accepted answer

Problem 1, Missing closing for the function

function Click(Player)
    if Player.IsInGroup(group.Value) then
        script.Parent.Script.Disabled = false   
    else
    script.Parent.Script.Disabled = true
end
end
script.Parent.Control1.SurfaceGui.TextButton.MouseButton1Click:connect(click)

Problem 2, Player:IsInGroup() not . It's a function so you need :

function Click(Player)
    if Player:IsInGroup(group.Value) then
        script.Parent.Script.Disabled = false   
    else
    script.Parent.Script.Disabled = true
end
end
script.Parent.Control1.SurfaceGui.TextButton.MouseButton1Click:connect(click)

if it works loike and accept You forgot to close the function, if any other problems occur comment and I'll edit accordingly if it worked +1 and accept

local groupid = "put your group id here"
function Click(Player)
    if Player:IsInGroup(groupid) then
        script.Parent.Script.Disabled = false   
    else
    script.Parent.Script.Disabled = true
end
end
script.Parent.Control1.SurfaceGui.TextButton.MouseButton1Click:connect(click)

1 comment

0

Nope

You need a click detector, Then add a function.

Button.Lighting.ClickDetector.IfTrue then
 FindFirstChild:Destroy

Hope this helped

3 comments

0

Don't need a click detector, it's a GUI

0

Oh

0

You're missing so much. That script wouldn't even work.

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