I honestly don't know why this isn't working, it works on my other game, exact same scripting, exact locations of all models and names, I just don't understand. Please someone help.
Error: Workspace.Part3.Script:10: attempt to index local 'Player' (a nil value)
local Players = game:GetService('Players') local debounce = false local Teleport = "Part4" function onTouched(hit) if debounce == false then debounce = true local OnTouchSky = game.ServerStorage.SkyChanger2 local OnTouchSkyCopy = OnTouchSky:Clone() local Player = Players:FindFirstChild(hit.Parent.Name) if Player.PlayerGui:FindFirstChild("SkyChanger") then if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true local Pos = script.Parent.Parent:findFirstChild(Teleport) hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end Player.PlayerGui.SkyChanger:Destroy() OnTouchSkyCopy.Parent = Player.PlayerGui debounce = false else if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true local Pos = script.Parent.Parent:findFirstChild(Teleport) hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end OnTouchSkyCopy.Parent = Player.PlayerGui debounce = false end end end script.Parent.Touched:Connect(onTouched)
You're not checking if the thing touching the part is a valid player:
Here's how you'd check
local Players = game:GetService('Players') local canTouch = true local Teleport = "Part4" function onTouched(hit) local isPlayer = hit.Parent:FindFirstChild("Humanoid") if(isPlayer)then if canTouch then canTouch = false local player = game.Players:FindFirstChild(hit.Parent.Name) local OnTouchSky = game.ServerStorage.SkyChanger2 local OnTouchSkyCopy = OnTouchSky:Clone() if player.PlayerGui:FindFirstChild("SkyChanger") then if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true local Pos = script.Parent.Parent:findFirstChild(Teleport) hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end player.PlayerGui.SkyChanger:Destroy() OnTouchSkyCopy.Parent = player.PlayerGui else if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true local Pos = script.Parent.Parent:findFirstChild(Teleport) hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end OnTouchSkyCopy.Parent = player.PlayerGui end end canTouch = true end end script.Parent.Touched:Connect(onTouched)
it also could be not working bc one game has filtering enabled off and this one has it on. if not then do what royaltoe says