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

How do I check if LocalPlayer is sitting on a Chair?

Asked by 3 years ago

Hello there,

I was messing around with the Default Template and while scripting i tried to make the game check if the LocalPlayer is sitting on Chair1 and if the Player is sitting on the Chair he should be assigned to the team "Russian Roulette". This is the Code i have so far. Please note that the Invisible Collider I made for Chair1 is a Part so the "Touched" function should work, However It doesnt print out anything, meaning that it doesnt even register the Touch, what am i doing wrong?

Btw im new to Roblox Studio

Thanks in advance!

local Chair1 = game.Workspace.ConstructionZone.CompleteHouse.Chair1.Collider
local Teams = game:GetService("Teams")
local Player = game:GetService("Players").LocalPlayer
local Character = game.Workspace:WaitForChild(Player.Name)

Player.Team = Teams.Chilling

function ConfirmC1()
    print("C1 touched!")
    Character.Team = Teams.RussianRoulette
    Character.TeamColor = Teams.RussianRoulette.TeamColor
end

Chair1.Touched:Connect(ConfirmC1)

1 answer

Log in to vote
0
Answered by 3 years ago

While the seat is occupied the player occupying the seat is seat.occupant (read devforum article)

Keep in mind you can't detect localplayer through serverscripts, only through local scripts. That's a common rookie mistake, just putting it out there.

About detecting if someone went on the seat i recommend you google things. There are devforum questions/articles about any problem you'll have. This is the article that i found

Good luck!

Ad

Answer this question