-
What do you want to achieve? Keep it simple and clear!
I want to fix a bug in my jump pad script -
What is the issue? Include screenshots / videos if possible!
So my jump pad model is working fine until I found this bug. My jump pad can be destroy if player use a tool to hit it enough so when a player use the jump pad to increase their jump power, another player can destroy the jump pad and then the player that use the jump pad will keep the increase jump power and not return to normal because the script inside is also destroyed -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried thinking but still found no solution
here’s my jump pad script
local Value = script.Parent.Parent.Uses
local deb = false
script.Parent.Parent.Picture.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.JumpPower == 50 then
if Value.Value > 0 and deb == false then
deb = true
hit.Parent.Humanoid.UseJumpPower = true
hit.Parent.Humanoid.JumpPower = 80
script.Parent.Boost:Play()
local Parti = game.ReplicatedStorage.Particle.Green:Clone()
Parti.Enabled = true
Parti.Parent = hit.Parent.Torso
Parti.Name = "PartiG"
local Trail = game.ReplicatedStorage.Trails.Green:Clone()
Trail.Parent = hit.Parent.Head
local At0 = Instance.new("Attachment", hit.Parent.Head)
At0.Name = "Attachment0"
local At1 = Instance.new("Attachment", hit.Parent.Torso)
At1.Name = "Attachment1"
Trail.Attachment0 = At0
Trail.Attachment1 = At1
Value.Value = Value.Value - 1
if Value.Value <= 0 then
script.Parent.Parent.Neon.Color = Color3.fromRGB(80,80,80)
script.Parent.Parent.Picture.Decal.Color3 = Color3.fromRGB(80,80,80)
end
wait(8)
hit.Parent.Humanoid.JumpPower = 50
local Ins0 = hit.Parent.Head.Attachment0
local Ins1 = hit.Parent.Torso.Attachment1
local InsTr = hit.Parent.Head.Green
local InsPa = hit.Parent.Torso.PartiG
Ins0:Destroy()
Ins1:Destroy()
InsTr:Destroy()
InsPa:Destroy()
if Value.Value <= 0 then
script.Parent.Parent:Destroy()
end
deb = false
end
end
end
end)
and here’s the breaking script
local Health = script.Parent.Break
local Bricks = script.Parent.Bricks
local S1 = script.Parent.Main.Hit
local S2 = script.Parent.Main.Hit2
Health.Changed:Connect(function()
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(0.25, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut, 0, true, 0)
local Goal = {Position = Vector3.new(script.Parent.Main.Position.X, script.Parent.Main.Position.Y + 1.5, script.Parent.Main.Position.Z)}
local Tween = TweenService:Create(script.Parent.Main, Info, Goal)
for i = 1,5 do
local Part = Instance.new("Part")
Part.CFrame = script.Parent.Main.CFrame
Part.CanCollide = false
Part.Anchored = false
Part.Parent = script.Parent.Folder
Part.AssemblyLinearVelocity = Vector3.new(math.random(-1,3)*math.random(10,11),50,math.random(-1,3)*math.random(10,11))
Part.Size = Vector3.new(0.5,0.5,0.5)
Part.Color = Color3.fromRGB(166,165,165)
Part.CastShadow = false
end
Tween:Play()
if Health.Value > 0 then
S1:Play()
end
if Health.Value == 0 then
S2:Play()
wait(0.25)
for i = 1, Bricks.Value do
local Children = game.ReplicatedStorage.Bricks:GetChildren()
local AmountOfChildren = #Children
local RandomPositionInArray = math.random(1, AmountOfChildren)
local RandomChild = Children[RandomPositionInArray]
local Brick = RandomChild:Clone()
local BrickMain = Brick:WaitForChild("Main")
Brick:SetPrimaryPartCFrame(CFrame.new(script.Parent.Main.Position))
Brick.Parent = game.Workspace.Bricks
BrickMain.AssemblyLinearVelocity = Vector3.new(math.random(-1,3)*math.random(10,11),50,math.random(-1,3)*math.random(10,11))
end
script.Parent:Destroy()
end
end)