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

Why does this work in studio but not in game? [Filtering Enabled]

Asked by 5 years ago

I made this scanner script that'll set an alarm off if you're not in the group, but it does it for everyone. Please help!

Disabler.MouseClick:Connect(function()
    Alarm:Stop()
    print("Alarm on")
    Light1.BrickColor = BrickColor.new("Dark green")
            Light2.BrickColor = BrickColor.new("Dark green")
            Light3.BrickColor = BrickColor.new("Dark green")
            wait(.001)
        Light1.BrickColor = BrickColor.new("Bright red")
            Light2.BrickColor = BrickColor.new("Bright red")
            Light3.BrickColor = BrickColor.new("Bright red")
            Alarm:Play()
            wait(26)
            Light1.BrickColor = BrickColor.new("Dark green")
            Light2.BrickColor = BrickColor.new("Dark green")
            Light3.BrickColor = BrickColor.new("Dark green")
            Alarm:Stop()
            print("Alarm off")
    end)
Scanner.Touched:Connect(function(Player)
    if debounce == false then
        debounce = true
        Scan:Play()
        Scanner.Transparency = .8
        wait(.6)
        Scanner.Transparency = .9
        if Rank <= 1 then
            print("Alarm on")
            Alarm:Stop()
            Light1.BrickColor = BrickColor.new("Dark green")
            Light2.BrickColor = BrickColor.new("Dark green")
            Light3.BrickColor = BrickColor.new("Dark green")
            wait(.001)
            Light1.BrickColor = BrickColor.new("Bright red")
            Light2.BrickColor = BrickColor.new("Bright red")
            Light3.BrickColor = BrickColor.new("Bright red")
            Alarm:Play()
            wait(26)
            Light1.BrickColor = BrickColor.new("Dark green")
            Light2.BrickColor = BrickColor.new("Dark green")
            Light3.BrickColor = BrickColor.new("Dark green")
            Alarm:Stop()
            print("Alarm off")
            end
            debounce = false
    end
end)
end)

Thanks if you can help

0
Is this a Server Script or Local Script? SBlankthorn 329 — 5y
0
Cause if it's Server, it's gonna do it for everyone, while if its Local, it will do it for one person. SBlankthorn 329 — 5y
0
I'll try a Local Script CaptainAlien132 225 — 5y
0
Nothing happens CaptainAlien132 225 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

You can solve this problem by using server script and remote event, When you use a remote event then it will make the script working on both server and client.

Go to the top of the script and type this:

local ReplicatedStorage = game:GetService("ReplicatedStorage") -- finds ReplicatedStorage
local createPartEvent = Instance.new("RemoteEvent") -- Creates the event
createPartEvent.Name = "AlarmEvent" -- The name of the event 
createPartEvent.Parent = ReplicatedStorage -- places the event on ReplicatedStorage

This may work for you as it did for me. Hope it helped!

0
Ty CaptainAlien132 225 — 5y
0
You're welcome SamirDevs 15 — 4y
Ad
Log in to vote
-1
Answered by
herrtt 387 Moderation Voter
5 years ago

Use player:IsInGroup() instead of rank

local groupId = 0 --group id
if plr:IsInGroup(groupId) then

else
    print("Alarm on!")
end

Answer this question