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:
01 | function onTouch(part) |
02 | local plr = game.Players:GetPlayerFromCharacter(part.Parent) |
03 | local Character = plr.Character or plr.CharacterAdded:wait() |
04 | local Torso = Character:WaitForChild( "Torso" ) |
05 | local enabled = false |
06 |
07 | if (plr ~ = nil ) then |
08 | if not enabled then |
09 | if plr.Name = = script.Parent.Parent.OwnerName.Value then |
10 |
11 | Torso.CFrame = CFrame.new(- 640.875 , - 84.657 , - 339.195 ) |
12 |
13 | enabled = true |
14 |
15 | else |
The script once more, but with my attempt (NOT WORKING)
01 | function onTouch(part) |
02 | local plr = game.Players:GetPlayerFromCharacter(part.Parent) |
03 | local Character = plr.Character or plr.CharacterAdded:wait() |
04 | local Torso = Character:WaitForChild( "Torso" ) |
05 | local enabled = false |
06 |
07 | if (plr ~ = nil ) then |
08 | if not enabled then |
09 | if plr.Name = = script.Parent.Parent.OwnerName.Value then |
10 |
11 | Torso.CFrame = CFrame.new(- 640.875 , - 84.657 , - 339.195 ) |
12 |
13 | enabled = true |
14 | elseif plr.Name = = script.Parent.Parent.OwnerName.Value and |
15 | if Character.Humanoid.Sit = = true or Character.Humanoid.PlatfromStand = = true then |
I cannot test it properly without the gui ect . This should work but let me know if there are any errors.
01 | function onTouch(part) |
02 | local plr = game.Players:GetPlayerFromCharacter(part.Parent) |
03 | local Wplr = part.Parent |
04 | local humanoid = Wplr:FindFirstChild( "Humanoid" ) |
05 | local enabled = false |
06 |
07 | if Wplr ~ = nil and humanoid ~ = nil then |
08 | print ( 1 ) |
09 | if not enabled then |
10 |
11 | --Check player name and if sitting then makes player stand |
12 | if Wplr.Name = = script.Parent.Parent.OwnerName.Value and not humanoid.sit then |
13 |
14 | Wplr.Torso.CFrame = CFrame.new(- 640.875 , - 84.657 , - 339.195 ) |
15 | enabled = true |
The humanoid located in a Player's Character has 3 proprieties of use to you
Jump
Sit
PlatformStand
These are all bool values.
If the player is sitting, Sit is true. Same with PlatformStand
You can check these values to see if the player is sitting or not.
Likewise, setting Jump to true will cause the player to jump, and is true when they are jumping.
A simple solution to your problem would be to cause the player to jump before you attempt to move them.
I would go through workspace finding all seats and connecting a event to Seated that triggers a function to fire a event that says who sat down and what seat so baisicly this
01 | function GetSeats(v,tab) |
02 | local Seats |
03 | if tab = = nil then |
04 | Seats = { } |
05 | else |
06 | Seats = tab |
07 | end |
08 | for _,part in next ,v:GetChildren() do |
09 | if part:IsA( "Seat" ) then |
10 | table.insert(Seats,part) |
11 | elseif part:GetChildren()~ = nil then |
12 | GetSeats(part,Seats) |
13 | end |
14 | end |
15 | return Seats |