I have encountered an "error". (It doesn't tell me anything in the output) On line 9 the If statement is getting ignored I think? And I have gone through the code and printed and stuff trying to figure out what the problem is but nothing. What it's supposed to happen is when the Punch Animation is played then the window should be able to break else if you just knock into it by accident nothing should happen but it still breaks if I knock into it. Why?
server script code:
local Glass = workspace.Glass_One local RemoteEv = game.ReplicatedStorage.RemoteEV.BreakGlassHammer local particle = Glass.ParticleEmitter local Shatter = game.ReplicatedStorage.Glass.Shatter local sound = Glass.Glass_Break RemoteEv.OnServerEvent:Connect(function(player) Glass.Touched:Connect(function(hit) if player.Animations:FindFirstChild("PlayingPunchAnim") and hit.Parent:FindFirstChild("RightHand") then wait(0.1) particle.Enabled = true wait(0.2) particle.Enabled = false Shatter.Parent = workspace Shatter.Anchored = true player.Character.Humanoid.Health = player.Character.Humanoid.Health -100 player.PlayerGui.DeathScreenGlass.Enabled = true Glass.Parent = game.ReplicatedStorage.Glass for i = 1,1 do sound:Play() wait(1) end wait(70) Shatter.Parent = game.ReplicatedStorage.Glass Glass.Parent = workspace else end end)