It’s pretty simple, I want a player to voluntarily sit into a chair (a seat part) and get XP. For now what I’m trying to obtain is that the player sits and is unable to leave until clicking a frame that will appear when they sit. I can’t get any result, and I’m confused. Any help?
Current Script
local hum = script.Parent.Humanoid
hum:GetPropertyChangedSignal("Sit"):Connect(function()
if hum.Sit.Value == true then
hum.JumpPower = 0
end
end)
I am a builder, and what I’m trying to obtain is complicated for me as I don’t script. I have deleted the prior script and I’m willing to write it again, however, I don’t know where to place the script or what sort of script it should be.
Player sits in a SEAT under workspace and obtains a value called XP that accumulates over each minute the player is in the SEAT. The value is reflected under a LEADERBOARD.
you can simply use a while loop to increase your XP value while sitting
here’s how i would do it
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local LeaveSeat = script.Parent -- assuming this script is a LocalScript inside the button
local XP = 0
local IsSitting = humanoid.Sit
humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
IsSitting = humanoid.Sit
humanoid.UseJumpPower = IsSitting -- since you don't want to jump while sitting
humanoid.JumpPower = IsSitting and 0 or 7 -- will only be 0 if you're sitting (IsSitting and 0) otherwise it's 7
LeaveSeat.Visible = IsSitting and true or false -- will only be visible if you are sitting
while IsSitting do
XP += 1 -- while sitting, increase XP by 1
print("You're Sitting. +1 XP:", XP)
task.wait(1)
end
end)
LeaveSeat.MouseButton1Click:Connect(function()
humanoid.Sit = false -- text button makes you stop sitting
end)