I dunno what to do with my teleport script because it dont teleporting player when touched. Output says " Workspace.Portal.PortalPart.Script:5: attempt to index nil with 'Character' ".
This is a script:
local scndChck = game.Workspace.SecondCheck local function touch(hit) local player = game.Players.LocalPlayer player.Character.HumanoidRootPart.CFrame = CFrame.new(scndChck.Position.X,scndChck.Position.Y + 5,scndChck.Position.Z) end script.Parent.Touched:Connect(touch)
Hello, you got messed up that CFrame set on line 7. I rewrited the script in shorter way and also fixed the code, here it is:
local scndChck = game.Workspace.SecondCheck script.Parent.Touched:Connect(function(part) local players = game:GetService("Players") if part.Parent:FindFirstChild("Humanoid") then local plr = players:GetPlayerFromCharacter(part.Parent) plr.Character.HumanoidRootPart.CFrame = scndChck.CFrame + Vector3.new(0,5,0) end end)
I wish you good luck in future scripting, have a nice day and I hope this helped.
local debounce = true script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if debounce == true then debounce = false hit.Parent.HumanoidRootPart.Position = Vector3.new(0,0,20) debounce = true end end end)
probs dont need debounce