No, just add
local Part = player.Backpack.Suitcase.detect
No, just add
local Part = player.Backpack.Suitcase.detect
It shows this error at line 10
You also forgot a “then” at the end of line 10.
Maybe try use WaitForChild
method. Some things can’t load on time, when server script is started, which is executed right away.
local partToLookFor = script.Parent.Parent.Parent.Parent.Teleporters.A
local TeleportPosition = CFrame.new(script.Parent.Parent.Parent.Parent.Teleporters.B.Position)
game.Players.PlayerAdded:Connect(function(player)
local backpack = player:WaitForChild("Backpack")
if backpack then
local Part = backpack:WaitForChild("Suitcase").detect
if Part then
Part.Touched:Connect(function(hit)
if hit == partToLookFor then
Part.CFrame = TeleportPosition
end
end)
else
print("Part is equal to nil")
end
else
print("Backpack is equal to nil")
end
end)
Alright il be testing it! Thank you to everyone!
Are you sure, that ‘Suitcase’ is inside Backpack?
YUP
It gets deleted when I equip it when playing the game.
I used the old script it works tho but my other script gives me an error.
Ah, this must be a problem, why script giving error. When you equipped tool, tool is moved to your character.
attempt to index nil with parent is the error what im trying to make here is for my tool to teleport to another part.
--Make sure that everything is held together
for _, part in ipairs(Item:GetDescendants()) do
if(part:IsA("BasePart") or part:IsA("MeshPart")) then
part.CanCollide = true
end
end
--
end)
I hope someone helps me solve this issue
Maybe this will work. Be sure that ‘Tool’ is inside backpack or your character.
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local backpack = player:WaitForChild("Backpack")
local character = player.Character or player.CharacterAdded:Wait()
local Item = backpack:FindFirstChild("Tool",true) or character:FindFirstChild("Tool",true)
if Item then
Item.Parent = script.Parent
Item:FindFirstChild("Handle").CFrame = script.Parent.Conveyor.CFrame + Vector3.new(0,3,0)
--Make sure that everything is held together
for _, part in ipairs(Item:GetDescendants()) do
if(part:IsA("BasePart") or part:IsA("MeshPart")) then
part.CanCollide = true
end
end
--
end
end)
Thank you il be trying that tomorrow!