Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Owner Only Seat script for UserId?

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.

1 comment

0

free script? what? the? heck?

2 answers

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.

2 comments

0

Doesn't work sadly, I've tested this and it doesn't work...

0

It's not my fault, its roblox updates. I'm used to the 2017 scripting.

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. ;)

This discussion is preserved as it was. New answers, comments, and votes are closed.