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()
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)
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)
---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)
--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)