my part isn’t deleting when I use :Destroy() on it
I get nothing in output.
the part just doesn’t delete…
local script:
wait(2)
-- // SERVICES // --
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
-- // VARIABLES // --
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Event = ReplicatedStorage.AbilityEvents:WaitForChild("GuardShield")
local Hum = Character:WaitForChild("Humanoid")
-- // CHECK // --
repeat
wait()
until
Character.Parent == workspace
-- // SCRIPT VARIABLES // --
local Holding = false
local Debounce = false
-- // SCRIPT // --
UIS.InputBegan:Connect(function(Input, gameProcessed)
if not gameProcessed and Debounce == false and Hum.ragdoll.Value == false and not Hum.PlatformStand and Hum.Health > 0 then
if Input.KeyCode == Enum.KeyCode.H and not Holding and not Debounce then
Event:FireServer("Begin", Player)
Debounce = true
Holding = true
while Holding and Character.Humanoid.WalkSpeed == 14 do
wait()
end
print(Holding)
wait(.5)
if Holding == false then
Event:FireServer("Finish", Player)
end
end
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.H and Holding and Debounce then
Holding = false
-- Event:FireServer("Finish", Player)
wait(5)
Debounce = false
end
end)
-- // EXTRA // --
ReplicatedStorage.ShieldCollisionOff.OnClientEvent:Connect(function()
local shield = Player.Character:WaitForChild("GuardShield")
shield.CanCollide = false
end)
server script:
-- // SERVICES // --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
-- // VARIABLES // --
local Event = ReplicatedStorage.AbilityEvents:WaitForChild("GuardShield")
local Shield = game.Workspace:FindFirstChild("GuardShield")
-- // SCRIPT // --
Event.OnServerEvent:Connect(function(Player, Type)
local Character = Player.Character
if Type == "Begin" then
local S = Shield:Clone()
S.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-4)
-- S.Attachment.ParticleEmitter.Enabled = true
local weld = Instance.new("WeldConstraint")
weld.Part0 = S
weld.Part1 = Character.HumanoidRootPart
weld.Parent = S
game.ReplicatedStorage.ShieldCollisionOff:FireClient(Player)
S.Orientation = Shield.Orientation
S.Parent = Character
S.Anchored = false
Character.Humanoid.WalkSpeed = 14
elseif Type == "Finish" then
Player.Character.GuardShield:Destroy()
Character.Humanoid.WalkSpeed = 16
end
end)
is there any alternative method to remove the part that would work?
First, these suggestions are brain corrupting.
Use a basic print to see whether the if statement is actually working. Then you can determine which lines are failing.
Try to print out Character.GuardShield on the server call within the remote and see if it exists and if not - it means you either need to use WaitForChild or check if lines above are valid.
-- // SERVICES // --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
-- // VARIABLES // --
local Event = ReplicatedStorage.AbilityEvents:WaitForChild("GuardShield")
local Shield = game.Workspace:FindFirstChild("GuardShield")
-- // SCRIPT // --
local S = nil
Event.OnServerEvent:Connect(function(Player, Type)
local Character = Player.Character
if Type == "Begin" then
S = Shield:Clone()
S.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-4)
-- S.Attachment.ParticleEmitter.Enabled = true
local weld = Instance.new("WeldConstraint")
weld.Part0 = S
weld.Part1 = Character.HumanoidRootPart
weld.Parent = S
game.ReplicatedStorage.ShieldCollisionOff:FireClient(Player)
S.Orientation = Shield.Orientation
S.Parent = Character
S.Anchored = false
Character.Humanoid.WalkSpeed = 14
elseif Type == "Finish" then
S:Destroy()
Character.Humanoid.WalkSpeed = 16
end
end)
idk why I set it as nil knowing I could by leaving it empty like this local S
make S a global variable or perhaps add it in a table. and remove the first member of le table.
I made S a global variable but “false” still doesnt print and neither does “found” so i don’t see how it would make a difference when trying to destroy the part