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

How do I make it activate on click?

Asked by 3 years ago

This script is inside an brick, how do I make this work when you click the brick?

local Cooldown = false

script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player)
    if Cooldown == true then return end
    if Player:IsInGroup(script.Parent.IsRestricted.Value) then
        if not Player.PlayerGui:FindFirstChild('NYPDBookPlayer') then
        if Player.Backpack:FindFirstChild('Grab') then
            if Player.Backpack.Grab.Suspect.Value then
                if game.Players:FindFirstChild(Player.Backpack.Grab.Suspect.Value) then
                    local Gui = game.ServerStorage.NYPDBookPlayer:Clone()
                    Gui.Parent = Player.PlayerGui
                    Gui.Suspect.Value = game.Players:FindFirstChild(Player.Backpack.Grab.Suspect.Value)
                    end
                end
            end
        end
    end
    Cooldown = false
end)    
0
Forgot to mention it also has an remote event and is restricted value inside teh brick Pancio10_alt 4 — 3y
0
The brick* Pancio10_alt 4 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

First thing first you need to add click detector inside the brick, and then you can use this script inside the brick. Here is the reference

local brick = script.Parent -- your brick
local click = brick.ClickDetector -- the clickdetector
click.MouseClick:Connect(function() --When you click the brick then
--Do what you want here
end)

i think this is the right code

local Cooldown = false
local brick = script.Parent -- your brick
local click = brick.ClickDetector -- the clickdetector
click.MouseClick:Connect(function(Player)
    if Cooldown == true then return end
    if Player:IsInGroup(script.Parent.IsRestricted.Value) then
        if not Player.PlayerGui:FindFirstChild('NYPDBookPlayer') then
        if Player.Backpack:FindFirstChild('Grab') then
            if Player.Backpack.Grab.Suspect.Value then
                if game.Players:FindFirstChild(Player.Backpack.Grab.Suspect.Value) then
                    local Gui = game.ServerStorage.NYPDBookPlayer:Clone()
                    Gui.Parent = Player.PlayerGui
                    Gui.Suspect.Value = game.Players:FindFirstChild(Player.Backpack.Grab.Suspect.Value)
                    end
                end
            end
        end
    end
    Cooldown = false
end)    

as i see here, you have a thing with remote event and i dont know where the fireserver(). So if you need to make a click detector inside a brick then you only need to do like i said earlier Let me know if it helps

0
I dont really understand, do I have to put the rest of the code after mouse click line? Pancio10_alt 4 — 3y
0
no you dont have to Blackbooks 138 — 3y
0
But anyways, thanks for answering. Pancio10_alt 4 — 3y
0
yeah you need more lesson on scripting Blackbooks 138 — 3y
Ad

Answer this question