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

How do I make it activate on click?

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)	

2 comments

0

Forgot to mention it also has an remote event and is restricted value inside teh brick

0

The brick*

1 answer

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

4 comments

0

I dont really understand, do I have to put the rest of the code after mouse click line?

0

no you dont have to

0

But anyways, thanks for answering.

0

yeah you need more lesson on scripting

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