ALL OF them work in F6 or solo mode but not in game mode. i know cuz scripts load faster than player, but how u fix it ?
I get this error: attempt to index field 'LocalPlayer' (a nil value) and i have no IDEA how to fix this
This script is confusing me alot, also this isn't a localscript it doesn't even work in a localscritp cuz its in a brick.
function teleportPlayer(pos, torso) local char = torso char.CFrame = CFrame.new(Vector3.new(pos.x, pos.y, pos.z)) end lvl = script.Parent.Parent.Parent.LevelValue Door = script.Parent script.Parent.Touched:connect(function(part) print("Door Hit") local human = part.Parent:FindFirstChild("Humanoid") if (human ~= nil) then print("Human touched door") local player = game.Players:GetPlayerFromCharacter(human.Parent) if (player == nil) then return end local stats = player:FindFirstChild("leaderstats") local sp = stats:FindFirstChild("test") if sp == nil then return false end print("Human passed test") else print("nope.avi") GUI = Instance.new("ScreenGui")-- problem here <<<<< GUI.Name = "ScreenGuiLVL" GUI.Parent = game.Players.LocalPlayer.PlayerGui
Also, why does even the error happen about player nil if this is in a brick ? it should get the player by touching ?
this script works everywhere else but not in-game.
function teleportPlayer(pos, torso) local char = torso char.CFrame = CFrame.new(Vector3.new(pos.x, pos.y, pos.z)) end lvl = script.Parent.Parent.Parent.LevelValue Door = script.Parent script.Parent.Touched:connect(function(part) print("Door Hit") local human = part.Parent:FindFirstChild("Humanoid") if human ~= nil then print("Human touched door") local player = game.Players:GetPlayerFromCharacter(human.Parent) if (player == nil) then return end local stats = player:FindFirstChild("leaderstats") local sp = stats:FindFirstChild("test") if sp == nil then return false end print("Human passed test") else print("nope.avi") GUI = Instance.new("ScreenGui") --creates a screen gui GUI.Parent = player.PlayerGui --Problem fixed. (Parents it) GUI.Name = "ScreenGuiLVL" --Gives it a name
LocalPlayer is not usable in a Normal Script. Click for more information.
The only way to access LocalPlayer from Players instance, is through localscript
Edit (6:22) - My bad nathan, didnt mean to give wrong idea, I removed it from answer Localscript LocalPlayer