Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do I check if player is Sit==true or PlatformStand==true? [ANSWERED]

Asked by 10 years ago

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:

01function 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 
13enabled = true
14 
15    else
View all 33 lines...

The script once more, but with my attempt (NOT WORKING)

01function 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 
13enabled = true
14                elseif plr.Name == script.Parent.Parent.OwnerName.Value and
15                if Character.Humanoid.Sit == true or Character.Humanoid.PlatfromStand == true then
View all 28 lines...

3 answers

Log in to vote
1
Answered by 10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

I cannot test it properly without the gui ect . This should work but let me know if there are any errors.

01function 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
View all 30 lines...
0
When I'm not the owner and I touch the Part, I get: attempt to index local 'plr' (a nil value) excellentAnarchy 50 — 10y
0
This might work, change line 2 :- local plr = game.Players:FindFirstChild (part.Parent) User#5423 17 — 10y
0
The same error excellentAnarchy 50 — 10y
0
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 User#5423 17 — 10y
View all comments (4 more)
0
The Gui is simply a StarterGui which goes into > game.Players.Player.PlayerGui excellentAnarchy 50 — 10y
0
I have uploaded http://www.filedropper.com/baseplate User#5423 17 — 10y
0
Oh, thank you! This one works :) I'd +1 you,but people on here have put my points down to -9 - haha :) excellentAnarchy 50 — 10y
0
just mark the thread as answered :) User#5423 17 — 10y
Ad
Log in to vote
0
Answered by
iaz3 190
10 years ago

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.

Log in to vote
-1
Answered by 10 years ago

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

01function 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
View all 27 lines...
0
So, how do I use it relating to my code? excellentAnarchy 50 — 10y
0
Please rep me if you like it nstrike159 15 — 10y

Answer this question