Hey there fellow dev!,
I’ve been working on a similar Jailbreak Casino Robbery for a video and ofcourse, I ran into some problems.
In the video below you can notice different errors:
The vault works like this:
You press E to start the cracking. After that you can press E again to rotate the vault-arms. (alternating between left and right). If you press E when the light is green 3 times in a row, you crack the vault and it’ll open. If you press E when the light is red, the vault stops and you have to re-crack it all over again.
The errors:
- Nothing happens when you press E before the first green light shows up (it should stop and reset everything so you have to restart the cracking mechanic
- If you press E after the first light shows, the mechanic stops but if you press E after that, it blocks for some reason and after you press another time, it’ll work but very glitchy. (it should just reset everything and work fine again)
- If you press E when it’s red, it’ll stop the mechanic but still continue the light mechanic.
My code:
The server script (ServerScriptService):
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local TweenInformation = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local Casino = workspace.Casino
local Vault = Casino.Vault
local MainVault = Vault.MainVault
local Light = MainVault.Light
local green = false
local red = true
function WeldModel(index)
for i = 1, #index:GetChildren() do
if index:GetChildren()[i] ~= index.PrimaryPart then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = index:GetChildren()[i]
Weld.Part1 = index.PrimaryPart
Weld.Parent = index.PrimaryPart
index:GetChildren()[i].Anchored = false
end
end
end
MainVault.RotationPart.EnableHack.Triggered:Connect(function(Player)
MainVault.RotationPart.EnableHack.Enabled = false
MainVault.RotationPart.RotatingVault.Enabled = true
ReplicatedStorage.Casino.RemoteEvents.Handler:FireAllClients("Rotate", MainVault, Light, MainVault.RotationPart)
end)
local currentTries = 0
MainVault.RotationPart.RotatingVault.Triggered:Connect(function(Player)
ReplicatedStorage.Casino.RemoteEvents.Handler:FireAllClients("Rotate", MainVault, Light, MainVault.RotationPart)
end)
ReplicatedStorage.Casino.RemoteEvents.Handler.OnServerEvent:Connect(function(Player, Argument, Additional1, Additional2)
if not Player then return end
if not Argument then return end
if Argument == "UpdateLights" then
Additional1.BrickColor = Additional2
elseif Argument == "FailHack" then
local Vault = Additional1
Vault.RotationPart.EnableHack.Enabled = true
Vault.RotationPart.RotatingVault.Enabled = false
elseif Argument == "SuccessHack" then
local Vault = Additional1
WeldModel(Vault)
local EndPart = Vault.Parent.EndPart
local Tween1 = TweenService:Create(Vault.PrimaryPart, TweenInformation, {CFrame = EndPart.CFrame, Orientation = EndPart.Orientation})
--local Tween2 = TweenService:Create(Vault.RotationPart, TweenInformation, {CFrame = EndPart.CFrame, Orientation = EndPart.Orientation})
--local Tween3 = TweenService:Create(Vault.Light, TweenInformation, {CFrame = EndPart.CFrame, Orientation = EndPart.Orientation})
--local Tween4 = TweenService:Create(Vault.Body, TweenInformation, {CFrame = EndPart.CFrame, Orientation = EndPart.Orientation})
Tween1:Play()
--Tween2:Play()
--Tween3:Play()
--Tween4:Play()
end
end)
The client script (StarterPlayer → StarterPlayerScripts):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Hack = false
local Light
local Green
local Red
local RotatingArm = false
local Arm
local Left = false
local currentTries = 0
function UpdateLights(Model, Color)
ReplicatedStorage.Casino.RemoteEvents.Handler:FireServer("UpdateLights", Model, Color)
end
ReplicatedStorage.Casino.RemoteEvents.Handler.OnClientEvent:Connect(function(Argument, Additional1, Additional2, Additional3)
if not Argument then return end
if Argument == "Rotate" then
local Vault = Additional1
Light = Additional2
Arm = Additional3
Hack = true
if Hack == true and Green == true then
Left = not Left
currentTries += 1
if currentTries == 3 then
ReplicatedStorage.Casino.RemoteEvents.Handler:FireServer("SuccessHack", Vault)
Hack = false
end
elseif Hack == true and Red == true then
currentTries = 0
ReplicatedStorage.Casino.RemoteEvents.Handler:FireServer("FailHack", Vault)
Hack = false
Arm = nil
Green = true
Red = false
end
end
end)
task.spawn(function()
while true do
if Hack == true and Arm ~= nil then
if Left == false then
Arm.CFrame *= CFrame.fromEulerAnglesXYZ(0.05, 0, 0)
elseif Left == true then
Arm.CFrame *= CFrame.fromEulerAnglesXYZ(-0.05, 0, 0)
end
end
task.wait(0.001)
end
end)
while true do
if Hack == true then
local randomTime1 = math.random() * 2.25 + .75
local randomTime2 = math.random() * 1 + .5
local randomTime3 = math.random() * .75 + .25
task.wait(randomTime1)
Light.BrickColor = BrickColor.new("Really red")
UpdateLights(Light, BrickColor.new("Really red"))
Green = false
Red = true
task.wait(randomTime2)
Light.BrickColor = BrickColor.new("Lime green")
UpdateLights(Light, BrickColor.new("Lime green"))
Green = true
Red = false
task.wait(randomTime3)
Light.BrickColor = BrickColor.new("Really red")
UpdateLights(Light, BrickColor.new("Really red"))
Green = false
Red = true
end
task.wait()
end
Question:
Does anybody know a solution? This is really frustrating for me and I’ve been working on this for 3 days and I can’t get it to work. Anything is appreciated. Thank you!
if you need the file of the game to help me, please throw me a dm. i do not feel comfortable sharing the file in the topic, but dms is fine.