Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Vehicle seat game pass won't work, problem?

Asked by 8 years ago
local passId = 379480149

function isAuthenticated(player) 
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end

script.Parent.VehicleSeat.ChildAdded:connect(function(obj)
    if game.Players:FindFirstChild(obj.Part1.Name) then
        plr = game.Players:FindFirstChild(obj.Part1.Name)
    end
    if plr and not isAuthenticated(plr) then
        plr.Character.Humanoid.Jump = true
        print(plr.Name.." is not authorized to use this vehicle")
    end
end)

I put this script into the seat of the vehicle which is named Drive, and the id is correct and I'm sure of that. Though when i try to test it with someone who doesn't have the pass, they can still drive it and they don't jump out. I tried to find the problem, but couldn't find it. Although "plr" on line 9 is underlined in blue. Can anyone help?

1
Try using the .Changed event to detect VehicleSeat changes, then utilize the Occupant property to get the humanoid driving the vehicle. Once you get the parent of the humanoid, you can use GetPlayerFromCharacter and get the player and then see if they own the game pass. If not use the humanoid to eject them from the seat. M39a9am3R 3210 — 8y
0
Um so how would that look like? :/ Supergamerboy1995 129 — 8y
0
Why not use the 'Touched' event to accomplish this? (The 'Touched' event works for (vehicle)seats too.) :) TheeDeathCaster 2368 — 8y
0
I tried the Touched event and couldn't seem to get it. Can someone show me a script and explain it please? Thanks. Supergamerboy1995 129 — 8y

Answer this question