When i sit on seat and close gui i cant able to sit on seat
Server Script:
task.wait(3)
local seat = script.Parent
local companys = game:GetService('Workspace'):WaitForChild('Companys')
local function onOccupantChanged()
local humanoid = seat.Occupant
if humanoid then
local character = humanoid.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local PlayerScripts = player:WaitForChild("PlayerScripts")
local PlayerModule = require(PlayerScripts:WaitForChild("PlayerModule"))
local PlayerControls = PlayerModule:GetControls()
if script.Parent.Parent.Parent.Parent:GetAttribute('Id') == player.UserId then
PlayerControls:Disable()
local gui = player.PlayerGui.Pc.PcUI
gui.Visible = true
else
seat:FindFirstChild('SeatWeld'):Destroy()
end
end
end
end
seat:GetPropertyChangedSignal("Occupant"):Connect(onOccupantChanged)
Client Script (local)
task.wait(3)
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerScripts = Player:WaitForChild("PlayerScripts")
local PlayerModule = require(PlayerScripts:WaitForChild("PlayerModule"))
local PlayerControls = PlayerModule:GetControls()
local playergui = Player.PlayerGui
local character = Player.Character
local humanoid = character:WaitForChild('Humanoid')
local Module = require(game:GetService('ReplicatedStorage'):WaitForChild('Module'))
local companys = game:GetService('Workspace'):WaitForChild('Companys')
script.Parent.MouseButton1Click:Connect(function()
local ownedCompany = nil
ownedCompany = Module.findCompany(Player)
ownedCompany:WaitForChild('PC1'):WaitForChild('Chair'):WaitForChild('Seat'):FindFirstChild("SeatWeld"):Destroy()
local gui = playergui.Pc.PcUI
gui.Visible = false
PlayerControls:Enable()
end)
task.wait(3)
local seat = script.Parent
local pl
local companys = game:GetService('Workspace'):WaitForChild('Companys')
local function onOccupantChanged()
local humanoid = seat.Occupant
if humanoid then
local character = humanoid.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local PlayerScripts = player:WaitForChild("PlayerScripts")
local PlayerModule = require(PlayerScripts:WaitForChild("PlayerModule"))
local PlayerControls = PlayerModule:GetControls()
if script.Parent.Parent.Parent.Parent:GetAttribute('Id') == player.UserId then
pl = player
PlayerControls:Disable()
local gui = player.PlayerGui.Pc.PcUI
gui.Visible = true
else
seat:FindFirstChild('SeatWeld'):Destroy()
end
end
end
end
seat:GetPropertyChangedSignal("Occupant"):Connect(onOccupantChanged)
local remote = game:GetService('ReplicatedStorage'):WaitForChild('SW')
remote.OnServerEvent:Connect(function(plr,something)
if plr.UserId == pl.UserId then
seat:FindFirstChild('SeatWeld'):Destroy()
local PlayerScripts2 = plr:WaitForChild("PlayerScripts")
local PlayerModule2 = require(PlayerScripts2:WaitForChild("PlayerModule"))
local PlayerControls2 = PlayerModule2:GetControls()
local gui1 = plr.PlayerGui.Pc.PcUI
gui1.Visible = false
PlayerControls2:Enable()
end
end)