ShowGUI on part touch not working on VehicleSeat

When I’m in a VehicleSeat does not work the script that should show me a GUI but if I’m on the foot works as it should.

Script 1:
local debounce = false

game.Workspace.Customization.Touched:Connect(function(hit)
if not debounce then
debounce = true

if game.Players:GetPlayerFromCharacter(hit.Parent)  then
	game.ReplicatedStorage.ShowGUI:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
end
wait(4)
	debounce = false
end

end)

Script 2(local script inside in GUI):
game.ReplicatedStorage.ShowGUI.OnClientEvent:Connect(function()

script.Parent.Enabled = not script.Parent.Enabled

wait(4)

script.Parent.Enabled = false

end)

1 Like

This is short but you can add what you want but to get the player you need to find the character first.

local seat = --path of seat
seat.Changed:Connect(function()
        local Char = seat.Occupant.Parent
        local Player = game.Players:GetPlayerFromCharacter(Char)
end)

if this doesnt work reply and ill help some more

Forgot One thing

local seat = --Path to Seat idk

seat.Changed:Connect(function(Changed)
    if Changed == "Occupant" and seat.Occupant then
        local Char = seat.Occupant.Parent
        local Player = game.Players:GetPlayerFromCharacter(Char)
        print(Player.Name) -- Just an example
    end
end)

How should I edit the script?(dadadadadada)

---Seat Script

local seat = ---Seat Path

seat.Changed:Connect(function(Changed)
    if Changed == "Occupant" and seat.Occupant then
        local Char = seat.Occupant.Parent
        local Player = game.Players:GetPlayerFromCharacter(Char)
        game:GetService("ReplicatedStorage").RemoteEvent:FireClient(Player)
    end
end)
--- Local Script inside the Gui whatever

game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(function()
    local GUI = ---Screen Gui Path
    
    GUI.Enabled = true
    
    wait(4)
    
    GUI.Enabled = false
end)

Also Keep all your script inside 3 of ` also with lua at the end.
You can do multiple of these. :slight_smile:

didn’t work and if I change the local script no longer appears the GUI.

What errors are there? Please tell.

Try this?

--Server Sided Script
local DB = false
local Seat = workspace.Customization
local Event = game.ReplicatedStorage:WaitForChild("ShowGUI")

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    print("Event fired")
    local Humanoid = Seat.Occupant
    if Humanoid then
        print("Found Humanoid")
        local Character = Humanoid.Parent
        local Player = game.Plauers:GetPlayerFromCharacter(Character)
 
        if Player then
            print("Found player, firing Remote")
            Event:FireClient(Player)
        end
    end
end) 
--Local Sided Script

local Event = game.ReplicatedStorage:WaitForChild("ShowGUI")

Event.OnClientEvent:Connect(function()
    script.Parent.Enabled = false
    wait(4)
    script.Parent.Enabked = true
end)

Pretty sure we forgot to parent the GUI to player Gui.