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

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

Asked by 5 years ago

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 answer

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago

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! :)

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. MeleeSoul 14 — 5y
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. MeleeSoul 14 — 5y
Ad

Answer this question