I’m currently almost finished with my lockdown system but when I press the lockdown button again (To end the lockdown) everything works but the LockdownGui will play because it was pressed…
Gui Code:
local button = game.Workspace.LockdownButton
local object = script.Parent
local clickdetector = button.ClickDetector
function onMouseClick(player)
object.AnchorPoint = Vector2.new(0, 0)
object.Position = UDim2.new(0.386, 0, -0.3, 0)
wait(0.5)
object:TweenPosition(UDim2.new(0.386, 0, 0, 0), 'Out', 'Quint', '4')
end
clickdetector.MouseClick:connect(onMouseClick)
Lockdown Code:
local sound = Instance.new("Sound", game.Workspace)
local reverb = Instance.new("ReverbSoundEffect", game.Workspace.Sound)
reverb.WetLevel = "-13"
sound.SoundId = "rbxassetid://4621098419"
local LockdownButton = script.Parent
local clickDetector = LockdownButton.ClickDetector
local clicked = false
local lights = game.Workspace.Lights
function onMouseClick()
if not clicked then
clicked = true
LockdownButton.BrickColor = BrickColor.Red()
sound.SoundId = "rbxassetid://4621098419"
sound.Playing = true
wait(9)
sound.Playing = false
sound.SoundId = "rbxassetid://394634971"
sound.Looped = true
sound.Playing = true
for k, light in pairs(lights:getChildren()) do
light.Light.Color= Color3.fromRGB(255, 58, 58)
end
else
clicked = false
LockdownButton.BrickColor = BrickColor.Green()
sound.Playing = false
sound.SoundId = "rbxassetid://1526192493"
sound.Playing = true
wait(4)
sound.Playing = false
for k, light in pairs(lights:getChildren()) do
light.Light.Color= Color3.fromRGB(255, 255, 255)
end
end
end
clickDetector.MouseClick:connect(onMouseClick)
local button = game.Workspace.LockdownButton
local object = script.Parent
local clickdetector = button.ClickDetector
function onMouseClick(player)
wait() -- seconds set by you
object.AnchorPoint = Vector2.new(0, 0)
object.Position = UDim2.new(0.386, 0, -0.3, 0)
wait(0.5)
object:TweenPosition(UDim2.new(0.386, 0, 0, 0), 'Out', 'Quint', '4')
end
clickdetector.MouseClick:connect(onMouseClick)
Remote Functions and Events (roblox.com) has a load of examples. But the one you want here is the Server to Client, the examples on the link here might help.
A question - do you want the GUI to be shown for just the player who pressed the button. Or should it show to all players (or all players on a particular team maybe??)
ok, pretty sure you would need to go with the remoteevents then, cos if you try to use the clickdetector like you do, it will only show up for the person who pressed the button.
Should not be too, hard is something like
Add a RemoteEvent to ReplicatedStorage, call it something. Here I’ve called it “LockdownEvent”
in your server code add somewhere at the top
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LockdownEvent = ReplicatedStorage:WaitForChild("LockdownEvent")
In your click handler in the server code, after you’ve gone into lockdown call the event saying lockdown has started; so something like
You then need a local script to handle this, so put anywhere a local script can run (starterplayerscripts or wherever you prefer)
Has same stuff at top to access the event
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LockdownEvent = ReplicatedStorage:WaitForChild("LockdownEvent")
local function onLockdownEvent(action)
if action == "start" then
--code to show GUI here
end
if action == "end" then
-- code to hide GUI here
end
end
LockdownEvent.OnClientEvent:Connect(onLockdownEvent)
If I’ve not got the hide/show logic right (e.g. if the GUI automatically hides after a few seconds instead, or something like that) then it would need a bit of changing round, but hopefully gives a start.
Allow the lockdown code to fire a RemoteEvent to one client(FireClient) or clients around(FireAllClients) whenever lockdown is initiated. The GUI code on the client should listen to this remote for it to display this GUI.
local button = game.Workspace.LockdownButton
local object = script.Parent
local clickdetector = button.ClickDetector
local db = false
function onMouseClick(player)
if db == false then
db=true
object.AnchorPoint = Vector2.new(0, 0)
object.Position = UDim2.new(0.386, 0, -0.3, 0)
wait(0.5)
object:TweenPosition(UDim2.new(0.386, 0, 0, 0), 'Out', 'Quint', '4')
end
end
clickdetector.MouseClick:connect(onMouseClick)