I tried using humanoid.Seated event but it didn't work. I want to make a script that deletes the car after a player gets up from a vehicleseat. I'm kinda new and I wanna know how to do it.
--local script-- local event = script.Parent.DeleteCar local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid") local audi = script.Parent.Parent --the car if not humanoid.Seated then event:FireServer(audi) end --server script-- local event = script.Parent.DeleteCar event.OnServerEvent:Connect(function(plr, car) car:Destroy() end)
i know the script is horribly wrong. I'm kinda new to scripting
This is very simple, just use GetProperty ChangeSignal look at the code below
local Players = game:GetService("Players") local seat = script.Parent local currentPlayer = nil seat:GetPropertyChangedSignal("Occupant"):Connect(function() local humanoid = seat.Occupant if humanoid then local character = humanoid.Parent local player = Players:GetPlayerFromCharacter(character) if player then currentPlayer = player return end end if currentPlayer then seat:Destroy() end end)