I have the code below which simply teleports the Player to a location if the Value within the model is == to the Player's name - Tycoon like owner. And if the Player isn't the owner then a GUI is show to him.
I would also like the script to check if the Player isn't seating because I have vehicles in the game, and being teleported with the vehicle would mess the game up, and I can't seem to figure it out..
The script without my attempt at checking if the player is seated:
function onTouch(part)
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
local Character = plr.Character or plr.CharacterAdded:wait()
local Torso = Character:WaitForChild("Torso")
local enabled = false
if (plr ~= nil) then
if not enabled then
if plr.Name == script.Parent.Parent.OwnerName.Value then
Torso.CFrame = CFrame.new(-640.875, -84.657, -339.195)
enabled = true
else
plr.PlayerGui.NotTheOwner.Frame.Visible = true
enabled = false
end
end
end
end
script.Parent.Touched:connect(onTouch)
--[[
Output:
Script:4: attempt to index local 'plr' (a nil value)
Even though there is an output for this, the script WORKS properly
--]]
The script once more, but with my attempt (NOT WORKING)
function onTouch(part)
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
local Character = plr.Character or plr.CharacterAdded:wait()
local Torso = Character:WaitForChild("Torso")
local enabled = false
if (plr ~= nil) then
if not enabled then
if plr.Name == script.Parent.Parent.OwnerName.Value then
Torso.CFrame = CFrame.new(-640.875, -84.657, -339.195)
enabled = true
elseif plr.Name == script.Parent.Parent.OwnerName.Value and
if Character.Humanoid.Sit == true or Character.Humanoid.PlatfromStand == true then
plr.PlayerGui.IsSeated.Frame.Visible = true
else
plr.PlayerGui.NotTheOwner.Frame.Visible = true
enabled = false
end
end
end
end
end
script.Parent.Touched:connect(onTouch)

8 comments
When I'm not the owner and I touch the Part, I get: attempt to index local 'plr' (a nil value)
This might work, change line 2 :- local plr = game.Players:FindFirstChild (part.Parent)
The same error
Where is the player gui? I managed to get it working, i put a gui in th starterpack and it worked using the code above
The Gui is simply a StarterGui which goes into > game.Players.Player.PlayerGui
I have uploaded http://www.filedropper.com/baseplate
Oh, thank you! This one works :) I'd +1 you,but people on here have put my points down to -9 - haha :)
just mark the thread as answered :)