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

Trying to make a lock script but I dont know how to get the player that sits in the seat?

Asked by
RootEntry 111
6 years ago

Hi, so I am trying to make a simple lock script. When you sit in the car its sets a value, "Owner". The Owner value is an object value that points to the player/the cars owner. But when I add a script to the seat and do:

script.Parent.ChildAdded:connect(function()
-- Something
end)

I cant get the player because it's a script. And in this example, I need the player's name to be able to confirm that they are the owner of the car.

This is the script right now:

script.Parent.ChildAdded:connect(function(driver)
    if script.Parent.Owner.Value ~= nil then
        if driver.Name == script.Parent.Owner.Value then
            print("Access Granted.")
        else
            driver.Character.Humanoid.Jump = true
            print("Access Denied.")
        end
    end
    print("grgrthgtr")
end)

But there is an error saying "07:36:44.482 - Character is not a valid member of Weld".

Please help me.

0
I am using A-Chassis btw. RootEntry 111 — 6y

Answer this question