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

How do i make so if someone clicks on a seat they will sit on it?

Asked by 7 years ago

I dont know how to do it.. ._______.

0
Put a invsible block on the seat with cancollie false and make it when they click the brick they tp to the cframe of the seat, making them sit. Make sure the block is invisible. yougottols1 420 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

OKay so I thought about it. Here is a way, I think will work. When a player is on top of a seat, he is automatically sat in it. so take that block you want to use as a button and paste the following in it:

local button = script.Parent
local telepad = game.Workspace.t1

button.MouseButton1Down:connect(function()
local teleport = telepads
Player = game.Players.LocalPlayer
Player.Character:MoveTo(teleport.Position)
end)

Then make a part that is named "t1" and place it inside the chair, just under where the player sits. Go into the properties and un-check Visible or set Transparency to 1 so that the part cannnot be seen. un-check CanCollide so that a player can walk through it. Now the player should be able to click the button, teleport to the top of the chair, and then he will automatically be sat down. Hope this helped :D

0
Oh xD yougootals1 I didn't notice you answered the same thing. My answer was more clear what to do though.Oh and xlGotDeleted, hes right about making it invisible. The_Jetcraft 7 — 7y
0
On the right track,but instead of using teleport pads,move the players torso position directly to the seat,then up 5 studs. Reshiram110 147 — 7y
0
I would post a code but i don't really feel like it XD.... yougottols1 420 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Ok so I really didn't feel like typing a piece of code, but here I am writing this anyway because it is almost 10 at night and I am bored. Anyway, you want a player to sit as soon as they click the seat? Correct? Thought so. So as I said before to accomplish this in a easy way just make a invisible block and put it on the seat, make sure the CanCollide is false and add a ClickDetector. I will demonstrate it, I will assume that the part and seat is already in workspace, if not then I will create two codes. One assuming it is and one assuming it is not.

---This is one assuming that the part and seat is already in workspace, this script will go in the part and I would assume the part already has a click detector in it. I would also assume that the part is covering the whole seat and the cancollide is false and etc. You get the bill.

local part = script.Parent
local seat = game.Workspace.Seat --Change the "Seat" to whatever the name of the Seat is in workspace, if you need to
part.ClickDetector.MouseClick:connect(function(click)
 local hum = click.Parent:FindFirstChild("Humanoid")
 if hum ~= nil then --I just always put this there no matter what, it is like a safety net per se
     click.Parent.Torso.CFrame = seat.CFrame --I would put +Vector3.new() but it would just tp you in the seat, thus making them auto sit in there. Thank you roblox
end
end)


-- This is the one assuming the part and seat is not in workspace...Yay...... Hopefully this is not the case o.o

game.Players.PlayerAdded:connect(function(plr) -- Don't worry I will make the workspace check for the part and seat before adding it so every player that joins doesn't put more and more seats and parts.
if game.Workspace:FindFirstChild("Click") and game.Workspace:FindFirstChild("Sit") == nil then
local seat = Instance.new("Seat") -- I don't put where you want the parent of the instance you created in the parenthesis when I am manipulating the properties of it, but that is just me
seat.Position = plr.Character.Torso.CFrame
seat.Name = "Sit"
seat.Parent = game.Workspace
local part = Instance.new("Part")
part.CanCollide = false
part.Transparency = 1
part.Size = Vector3.new(5,5,5)
part.Parent = game.Workspace
part.CFrame = seat.CFrame
part.Name = "Click"
local detector = Instance.new("ClickDetector")
detector.Parent = part

game.Workspace.Click.ClickDetector.MouseClick:connect(function(clicked)
 local hum = clicked.Parent:FindFirstChild("Humanoid")
 if hum ~= nil then
    clicked.Parent.Torso.CFrame = game.Workspace.Sit.CFrame
end
end
end)
end)


Overall if this helped you at all please give a thumbs up and accept my answer. If this errored at all and/or you have any questions please comment on my answer, I will be glad to help. Hope this helped!

Answer this question