hello i need help on my king crimson time erase as im making a jojo game. While im in the time erase mode i dont know how to stop it unless i wait for it to end, is there a way i can cancel the time erase if i press F again? heres my script:
local UIS = game:GetService(“UserInputService”)
local Map = game.Workspace[“Dont got time for thia”]
local Skybox = game.Workspace[“Purple Nebula”]
local Map2 = game.Workspace.Models
local Road = game.Workspace.Road
local Water = game.Workspace.Terrain
local Sun = game.Lighting.SunRays
local debounce = false
local active = false
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.F then
game.Workspace.Camera.FieldOfView = 100
wait(.2)
game.Workspace.Camera.FieldOfView = 70
for i, v in ipairs(Map:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
end
end
for i, v in ipairs(Map2:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
end
end
for i, v in ipairs(Road:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
end
end
Sun.Enabled = false
Water.Transparency = 1
Skybox.Parent = game.Lighting
wait(20)
game.Workspace.Camera.FieldOfView = 100
wait(.2)
game.Workspace.Camera.FieldOfView = 70
Skybox.Parent = game.Workspace
Water.Transparency = 0
Sun.Enabled = true
for i, v in ipairs (Map:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
for i, v in ipairs(Map2:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
end
end
for i, v in ipairs(Road:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
end
end
end
end
end
end)
ive tried to copy some code from my stand summon code to see if i can do that again but doesn’t seem to work either, i would appreciate some scripting help.
Yeah I believe you can do that easily set a new variable local Enabled = false
Now edit this part
if input.KeyCode == Enum.KeyCode.F and Enabled = false then
Enabled = true
--Enable the mode here
elseif input.KeyCode == Enum.KeyCode.F and Enabled = true then
Enabled = false
--Disable the mode
Edit: changed the Enabled values in the UIS since I had it written the wrong way
That just adds an extra unnecessary check, for this case flipping the boolean is more than enough.
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then
return
end
if input.KeyCode == Enum.KeyCode.F then
enabled = not enabled
if enabled then — activate ability
else — de-activate ability
end
end
end)
This is also a lot cleaner and easier to understand.
hi i dont know if im doing it wrong but the script still doesnt cancel when i press F again, heres the script:
local UIS = game:GetService(“UserInputService”)
local Map = game.Workspace[“Dont got time for thia”]
local Skybox = game.Workspace[“Purple Nebula”]
local Map2 = game.Workspace.Models
local Road = game.Workspace.Road
local Water = game.Workspace.Terrain
local Sun = game.Lighting.SunRays
local enabled = not enabled
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return
end
if input.KeyCode == Enum.KeyCode.F then
enabled = not enabled
if enabled == enabled then
Skybox.Parent = game.Lighting
game.Workspace.Camera.FieldOfView = 100
wait(.2)
game.Workspace.Camera.FieldOfView = 70
for i, v in ipairs(Map:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
end
end
for i, v in ipairs(Map2:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
end
end
for i, v in ipairs(Road:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
end
end
Sun.Enabled = false
Water.Transparency = 1
wait(20)
game.Workspace.Camera.FieldOfView = 100
wait(.2)
else
game.Workspace.Camera.FieldOfView = 70
Skybox.Parent = game.Workspace
Water.Transparency = 0
Sun.Enabled = true
for i, v in ipairs (Map:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
for i, v in ipairs(Map2:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
end
end
for i, v in ipairs(Road:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
end
end
end
end
When you’re using booleans you don’t need to do a strict == check, you can simply do if bool then for checking if a value is true, and if not bool then for checking a falsey value like false.
The problem with your check is you don’t really do anything. For example, if your enabled value is false, you’re quite literally doing, if false == false then or if true == true then. To fix it just use 2 separate blocks, one for activate and one for deactivation.