For some reason, my break doesn’t seem to be working.
I apologize for the messy-coding, I’ll organize it soon
Output:
-
these prints are from the LocalScript from FireAllClients()
-
randomly, it fires false twice then it goes back to true. (Which isn’t what’s supposed to happen)
-
also near the end of the LocalScript, the break doesn’t seem to, of course break, which is what I assume the main culprit behind the error.
Server-Script:
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local Assets = ReplicatedStorage.Assets
local VFX = ReplicatedStorage.VFX
local SFX = ReplicatedStorage.SFX
local NukeRE = Events:FindFirstChild("Nuke")
local CameraShakeRE = Events:FindFirstChild("CameraShake")
NukeRE.OnServerEvent:Connect(function(Player, Tool)
local Character = Player.Character
Tool.Handle:Destroy()
Tool.Enabled = false
Tool.Parent = workspace
local NukeActivated = false
local Nuke = Assets.Nuke:Clone()
local NukeVFX = VFX.NukeVFX:Clone()
Nuke.PrimaryPart.Position = Tool.Main.Position + Vector3.new(0,1000,0)
NukeVFX.InnerNuke.Touched:Connect(function(HitPart)
local success, errormsg = pcall(function()
if HitPart then
local Character = HitPart.Parent
if Character:IsA("Model") then
local Humanoid = Character.Humanoid
if Humanoid:IsA("Humanoid") then
Humanoid.Health = 0
for _, bodypart in pairs(Character:GetDescendants()) do
if bodypart:IsA("BasePart") then
bodypart.BrickColor = BrickColor.new("Really black")
elseif bodypart:IsA("Accessory") then
bodypart.Handle.BrickColor = BrickColor.new("Really black")
end
end
end
end
end
end)
end)
Nuke.Parent = workspace
Nuke.PrimaryPart.Touched:Connect(function(HitPart)
if HitPart then
NukeActivated = true
warn("Nuke Unleashed, plr="..Player.Name)
NukeVFX:SetPrimaryPartCFrame(Nuke.PrimaryPart.CFrame)
CameraShakeRE:FireAllClients(true)
Nuke:Destroy()
NukeVFX.Parent = workspace
local NukeSound = SFX:WaitForChild("NukeSound"):Clone()
NukeSound.Parent = NukeVFX.PrimaryPart
NukeSound:Play()
for i = 1, 225, 1 do
task.wait()
NukeVFX:ScaleTo(i)
end
for i = 225, 250, .5 do
task.wait()
NukeVFX:ScaleTo(i)
end
for i = 0, 1, 0.01 do
task.wait(0.025)
for _, part in pairs(NukeVFX:GetDescendants()) do
if part:IsA("BasePart") then
part.Transparency = i
end
end
end
NukeVFX:Destroy()
CameraShakeRE:FireAllClients(false)
end
end)
end)
LocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Events = ReplicatedStorage:WaitForChild("Events")
local CameraShakeRE = Events:WaitForChild("CameraShake")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
CameraShakeRE.OnClientEvent:Connect(function(Activated)
print(Activated)
while true do
if Activated == true then
print(Activated)
task.wait()
local xoffset = math.random(-100,100) / 500
local yoffset = math.random(-100,100) / 500
local zoffset = math.random(-100,100) / 500
Humanoid.CameraOffset = Vector3.new(xoffset,yoffset,zoffset)
else
print(Activated)
task.wait()
Humanoid.CameraOffset = Vector3.new(0,0,0)
break
end
end
end)