I have recently made two scripts that took me hours to make, when you combine the multiple bug and error fixes, I had to make in them. Now they’ve completely broken and neither work as intended. The script for the cart that attaches a new rope between the players Right Arm
and the RopePart
doesn’t work, and for the other script, it works, but the parts that are created are unanchored but stuck floating in the air.
There are no errors that specifically point out to what I did wrong. so how do I fix this?
Cart Script
local pp = script.Parent
local clicked = 0
local cooldown = false
pp.Triggered:Connect(function(player)
if player.Name == pp.Parent:GetAttribute("Ownership") and clicked == 0 then
if not cooldown then cooldown = true elseif cooldown then return end
local transportVehicle = pp.Parent.Parent
clicked += 1
local playerChar = player.Character
local RightArm = playerChar:FindFirstChild("Right Arm")
local Rope = Instance.new("RopeConstraint", RightArm)
Rope.Name = "Rope"
Rope.Visible = true
Rope.Attachment0 = Instance.new("Attachment", RightArm)
Rope.Attachment0.Name = "RopeConstraintAttatchment"
Rope.Attachment1 = Instance.new("Attachment", transportVehicle:WaitForChild("RopePart"))
Rope.Attachment1.Name = "RopeConstraintAttatchment"
task.wait(.558)
cooldown = false
elseif player.Name == pp.Parent:GetAttribute("Ownership") and clicked == 1 then
if not cooldown then cooldown = true elseif cooldown then return end
local transportVehicle = pp.Parent.Parent
clicked -= 1
local playerChar = player.Character
local RightArm = playerChar:FindFirstChild("Right Arm")
local Rope = RightArm:WaitForChild("Rope")
Rope:Destroy()
task.wait(.558)
cooldown = false
end
end)
15:17:36.689 Workspace.Transporter.RopePart.AttatchRopeToPlayer.AttatchScript:33: attempt to index nil with 'WaitForChild' - Server - AttatchScript:33
15:17:36.689 Stack Begin - Studio
15:17:36.689 Script 'Workspace.Transporter.RopePart.AttatchRopeToPlayer.AttatchScript', Line 33 - Studio - AttatchScript:33
15:17:36.689 Stack End - Studio
Mineral Script
local tool = script.Parent
local toolDamage = tool:GetAttribute("Damage")
local guiElements = tool:WaitForChild("GUI")
local remote = tool:WaitForChild("RemoteEvent")
local RS = game:GetService("ReplicatedStorage")
local Blocks = RS:WaitForChild("Blocks")
remote.OnServerEvent:Connect(function(player, char, mineral)
toolDamage = tool:GetAttribute("Damage")
if mineral:FindFirstChild("Progress") and mineral:GetAttribute("damageDone") then
print("true")
local MaxHealth = mineral:GetAttribute("MaxHealth")
local damageDone = mineral:GetAttribute("damageDone")
print(mineral:GetAttribute("damageDone"))
print(mineral:GetAttribute("MaxHealth"))
print(damageDone)
print(mineral.Size.X + mineral.Size.Y)
mineral:SetAttribute("damageDone", damageDone + toolDamage)
mineral:WaitForChild("Progress"):WaitForChild("ProgressBar").Size = UDim2.new(damageDone/MaxHealth, 0, 1, 0)
if damageDone >= MaxHealth then
for i = 1, mineral.Size.X do
for index, block in pairs(Blocks:GetChildren()) do
if block.Color == mineral.Color then
local mineralPiece = block:Clone()
mineralPiece.Parent = workspace:WaitForChild("MineralPieces")
mineralPiece.Position = mineral.Position
mineralPiece.Anchored = false
end
end
end
mineral:Destroy()
end
elseif not mineral:FindFirstChild("GUI") and mineral:GetAttribute("damageDone") then -- <--
print("false")
for i, v in pairs(guiElements:GetChildren()) do
local guiClone = v:Clone()
guiClone.Parent = mineral
for ii, vv in pairs(guiClone:GetChildren()) do
vv.BackgroundTransparency = 0
vv.TextTransparency = 0
end
end
end
end)