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

Owner Only Seat script for UserId?

Asked by
baxzzi 42
6 years ago

So I've gotten a free script that only works with usernames however, I'm trying to change it to detect the userId. Please help, thank you! local seat = script.Parent

seat.ChildAdded:connect(function( newChild )    
    if newChild:IsA("Weld") then
        if newChild.Part1.Name == "HumanoidRootPart" then
            local player = game.Players:GetPlayerFromCharacter(newChild.Part1.Parent)
            if (player) then
                if player.UserId == script.Parent.Parent.Name then
                    --code here or leave blank
                else
                    newChild.Part1.Parent.Humanoid.Health = 0 -- kills player
                end
            end
        end
    end
end)

The folder the seat is in is named after the player's userid, there's two parents.

0
free script? what? the? heck? GingeyLol 338 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Ok, here it is.

local seat = script.Parent -- gets seat
game.Players.PlayerAdded:connect(function(p) -- checks if player has added
    local owner = Instance.new("StringValue",p) -- adds a string value to the player
    owner.Name = "OwnerValue" -- names the value OwnerValue
    owner.Value = "nil" -- this will be changed to either true or false
    if (p.UserId == game.CreatorId) then -- checks if player user id is the creator id
        owner.Value == "true" -- sets owner value to true
    else
        owner.Value == "false" -- sets owner value to false
    end
    p.CharacterAdded:connect(function(char) -- checks if character is added
        wait() -- about the quickest tick you can get, any faster will make you lag
        local h = char.Humanoid -- gets the humanoid
        h.Changed:connect(function() -- checks if humanoid has changed any value
            if (h.SeatPart == seat) and (owner.Value=="false") then -- checks if on seat and not owner
                char:BreakJoints() -- kills the player
            end
        end)
    end)
end)

You could make a religion out of this.

0
Doesn't work sadly, I've tested this and it doesn't work... baxzzi 42 — 6y
0
It's not my fault, its roblox updates. I'm used to the 2017 scripting. CrastificeDude612 71 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

At code here or leave blank, leave it blank. In the future, try not to use free scripts. But great job trying to edit it. ;)

Answer this question