Local Script:
local player = game:GetService("Players").LocalPlayer
local tween = game:GetService("TweenService")
local debounce1 = true
local debounce2 = true
local function dynamiteTouched()
if script.Parent:WaitForChild("DynamiteValue").Value ~= nil then
script.Parent:WaitForChild("DynamiteValue").Value.Touched:Connect(function(hit)
if hit.Name == "HitBox1Train" and debounce1 == true then
wait(0.3)
debounce1 = false
local cloneText = player.PlayerGui.PowerUp.plusPower:Clone()
cloneText.Parent = player.PlayerGui.PowerUp
cloneText.Visible = true
cloneText.Name = "plusPowerClone"
cloneText.countText.Text = player.Data.PlusDamage.Value
cloneText.Position = UDim2.new(math.random(100, 800)/1000, 0, math.random(200, 800)/1000, 0)
local targetSize = UDim2.new(0.093, 0, 0.181, 0)
local tweenInfo = TweenInfo.new(0.3)
local damageCount = player.PlayerGui.ShowStatsUnder.Damage
local targetPosition1 = UDim2.new(0.4, 0, -0.02, 0)
local targetPosition2 = UDim2.new(0.4, 0, 0, 0)
local tweenInfo1 = TweenInfo.new(0.9)
local tweenPosition1 = tween:Create(damageCount, tweenInfo1, {Position = targetPosition1})
tweenPosition1:Play()
local tweenSize = tween:Create(cloneText, tweenInfo, {Size = targetSize})
tweenSize:Play()
player.Data.DamageCount.Value = player.Data.DamageCount.Value + player.Data.PlusDamage.Value
wait(0.1)
local tweenPosition2 = tween:Create(damageCount, tweenInfo1, {Position = targetPosition2})
tweenPosition2:Play()
wait(0.8)
cloneText:Destroy()
debounce1 = true
end
if hit.Name == "Sand_1" and debounce2 == true then
debounce2 = false
hit:FindFirstChild("Current").Value -= player.Data.DamageCount.Value
print(hit.Name)
hit:FindFirstChild("SurfaceGui").HpCount.Text = hit:FindFirstChild("Current").Value.. " / ".. hit:FindFirstChild("Max").Value
local surfaceGui = hit:FindFirstChild("SurfaceGui")
local greenGround = surfaceGui.GreenGround
--local targetSize = UDim2.new(hit:FindFirstChild("Current").Value / hit:FindFirstChild("Max").Value, 0, 1, 0)
--local targetPosition = UDim2.new(targetSize.X.Scale * -0.5, 0, 0, 0)
greenGround:TweenSize(UDim2.new(hit:FindFirstChild("Current").Value / hit:FindFirstChild("Max").Value, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1)
--hit:FindFirstChild("SurfaceGui").GreenGround:TweenSize(UDim2.new(hit:FindFirstChild("Current").Value / hit:FindFirstChild("Max").Value, 0, 0, 0), 1)
if hit:FindFirstChild("Current").Value <= 0 then
wait(0.1)
hit.Parent = game:GetService("ReplicatedStorage")
local vfx = workspace.Smoke_1:Clone()
vfx.Parent = workspace.vfx
vfx.Position = hit.Position
vfx.Anchored = true
vfx.ParticleEmitter:Emit()
print(hit.Name, "Was destroyed")
end
wait(1)
debounce2 = true
elseif hit.Name == "Sand_2" and debounce2 == true then
debounce2 = false
print("Sand2 Damage")
hit:FindFirstChild("Current").Value -= player.Data.DamageCount.Value
hit:FindFirstChild("SurfaceGui").HpCount.Text = hit:FindFirstChild("Current").Value.. " / ".. hit:FindFirstChild("Max").Value
local surfaceGui = hit:FindFirstChild("SurfaceGui")
local greenGround = surfaceGui.GreenGround
greenGround:TweenSize(UDim2.new(hit:FindFirstChild("Current").Value / hit:FindFirstChild("Max").Value, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1)
if hit:FindFirstChild("Current").Value <= 0 then
wait(0.1)
hit:Destroy()
local vfx = workspace.Smoke_1:Clone()
vfx.Parent = workspace.vfx
vfx.Position = hit.Position
vfx.Anchored = true
vfx.ParticleEmitter:Emit()
print("Sand2 was destroyig")
end
wait(1)
debounce2 = true
end
end)
end
end
script.Parent:WaitForChild("DynamiteValue"):GetPropertyChangedSignal("Value"):Connect(dynamiteTouched)
So I have a script… The most important line is 67. That’s where I try to move the part to another location. But for some reason, when I destroy a wall. Then its hitbox happens, and I can not pass on. Why?