Hello,
I’m making a seat lock for my bus. I did almost everything, but the FireClient isn’t working. There are two scripts. The main server script and a serverscript, which RunContext is set to Client. In the main server script everything works, except the FireClient. I’ve put print statments and after the FireClient, in the server script with the different RunContext, it doesn’t print.
Can someone help? Below, I will send the code.
Main server script
local function onSit()
if db then db=false task.wait(0.033)
local seat2 = script.Parent.Parent.Parent.Parent.Parent.DriveSeat
local part = workspace.Part
local seatplayer = seat.Occupant.Parent
print(seatplayer)
print("działa do tej pory")
if seat2:GetPropertyChangedSignal("Occupant") then
if seat2.Occupant then
print('smooth')
local occupant = seat.Occupant
print('smooth')
local char = occupant.Parent
print('smooth')
local username = char.Name
print('smooth')
print(username)
local Player = Players:GetPlayerFromCharacter(seat2.Occupant.Parent)
print(Player)
print(Player.Character)
local PlayerGui = Player:FindFirstChild("PlayerGui")
print(PlayerGui)
print('doszło do tego momentu')
print(PlayerGui:FindFirstChild("A-Chassis Interface").AntiJump.Value)
if PlayerGui:FindFirstChild("A-Chassis Interface").AntiJump.Value == true then
print('przeszło')
local osoba = seat.Occupant.Parent
local player = Players:GetPlayerFromCharacter(seat.Occupant.Parent)
print(seatplayer)
NewGui.On.Enabled = true
NewGui.Off.Enabled = false
print('works')
unbindaction:FireClient(player)
end
if PlayerGui:FindFirstChild("A-Chassis Interface").AntiJump.Value == false then
local osoba = seat.Occupant.Parent
local player = Players:GetPlayerFromCharacter(seat.Occupant.Parent)
print(seatplayer)
NewGui.On.Enabled = true
NewGui.Off.Enabled = false
bindaction:FireClient(player)
end
end
end
db = true
end
end
Server script with Client RunContext
local unbindaction = script.Parent.unbindaction
local bindaction = script.Parent.bindaction
local ContextActionService = game:GetService('ContextActionService')
bindaction.OnClientEvent:Connect(function()
print('a')
wait(0.1)
ContextActionService:BindAction("jumpAction", Enum.UserInputState, false, Enum.KeyCode.Space)
print('binded')
end)
unbindaction.OnClientEvent:Connect(function()
wait(0.1)
ContextActionService:BindAction("jumpAction")
print('unbinded')
end)
Aswell I have a second question. Is the ContextActionService done correctly so the user can’t jump out of the seat?
Kind regards