Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Force a player out of a seat with a global script?

I'm attempting to make it so when certain requirements are met, the player will be forced out of the seat they are in (by forcing them to jump) but I haven't found a way to get their character with a global script. I don't want to use a local script, so PLEASE don't suggest the idea. I'll understand if i'm simply just told there is no way to get the player with a global script.

Important part of code:

power = workspace.Power

power.Changed:connect(function(newValue)
	script.Parent.Info.SurfaceGui.Power.Text = "Power: "..newValue.."%"
	if newValue <= 0 then
		if workspace.OfficeChair.CamSeat.Occupant ~= nil then
		local hum = workspace.OfficeChair.CamSeat.Occupant
		local par = workspace:WaitForChild(hum.Parent)
		par:FindFirstChildOfClass("Humanoid").Jump = true
		elseif workspace.OfficeChair.CamSeat.Occupant == nil then print("") end
		workspace.Usage.Value = 0
		workspace.ComputerEnabled.Value = false
		workspace.Door1.Value = false
		workspace.Door2.Value = false
		workspace.LightEnabled.Value = false
		workspace.ComputerToggle.ClickDetector.MaxActivationDistance = 0
		workspace.Door1Switch.DoorButton.ClickDetector.MaxActivationDistance = 0
		workspace.Door2Switch.DoorButton.ClickDetector.MaxActivationDistance = 0
		workspace.LightSwitch.LightButton.ClickDetector.MaxActivationDistance = 0
	end
end)

1 comment

1 answer

Well you already found the humanoid. To get the character, you can either get the humanoid's parent, or use the .Character property on player.

local humanoid = ...
local player = ...
local character = humanoid.Parent
-- or 
local character = player.Character

Hope this helps! :)

2 comments

0

I've already attempted to get the Humanoid's parent, and I highly doubt that i'll be able to get even the player.

0

I've also attempted to simply just get the Humanoid with the Occupant property of the Seat, then force it to jump, but for some reason it doesn't work and the output doesn't tell why.

This discussion is preserved as it was. New answers, comments, and votes are closed.