Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why will this object not get destroyed?

Asked by 5 years ago

game.Workspace.EnergyBarShop.EnergyBarShopItem.ClickDetector.MouseClick:Connect(function(plr)

if plr.leaderstats.Money.Value >= 20000 then

plr.leaderstats.Money.Value = plr.leaderstats.Money.Value - 20000

EnergyBar = game.ServerStorage.EnergyBar:Clone()

EnergyBar.Parent = plr.Backpack

end

end)

game.ReplicatedStorage.EnergyBarEffects.OnServerEvent:Connect(function(plr)

local Character = game.Workspace[plr.Name]

Character.Humanoid.Health = Character.Humanoid.Health + 100

Character.Humanoid.WalkSpeed = 21

wait(25)

Character.Humanoid.WalkSpeed = 16

EnergyBar:Destroy()

end)

0
It does not look like you ever send the remote event. To me it seems like you should just make the code one long code Instead of having the remote event? OBenjOne 190 — 5y
0
We need to know what fires the remote event and when as this could be the problem OBenjOne 190 — 5y
0
It does everything else in the script except for that jhawkes145 0 — 5y
0
Why are you getting the character like that? You already have 'plr' as it gets passed through a remoteevent by default, just do local Character = plr.Character or plr.CharacterAdded:Wait() awfulszn 394 — 5y

Answer this question