I want to be able to have a string value with a player's name so that only that player can sit in a Seat object, if it is not the player then kill the person sitting in the chair
I'm not sure if this is correct, you may need to double check this:
seat = SEAT PATH HERE access = {"fahmisack123" , "fahmisack123", etc..} function Check(Player) --Sets a function player = Player.Parent:FindfirstChild("Humanoid") --Checks if it's a character if player ~= nil and player.Name ~= #access then --If it IS a character AND has their name in the access table then... player.Health = 0 --...Kill end end while true do --So it happens many times, not only once seat.Touched:connect(Check) --Calls the function wait() --Makes sure Studio and the game doesn't crash end ----------------------- PLEASE NOTE ----------------- THIS MAY NOT BE CORRECT AS I AM NOT A PERFECTLY GOOD SCRIPTER -----------------------------------------------------
This would be the best way to do it:
local Seat = SEAT_PATH_HERE local Access = {"TurboFusion","wargod435",...} function IsAccess(Player) for _,v in pairs(Access) do --Iterates through the Access table if string.lower(Player.Name) == string.lower(v) then --Checks to see if the player's name is in the table return true end end return false end Seat.ChildAdded:connect(function(Child) --This event fires whenever a child is added to the seat if Child.Name == "SeatWeld" then --If the child is a seatweld... local Player = game.Players:GetPlayerFromCharacter(Child.Part1.Parent) --Gets the player if Player then --If the player exists... if IsAccess(Player) then --Calls the IsAccess function and checks if it's true --Do stuff else --if it's false... Player.Character.Humanoid.Health = 0 --Kills the player end end end end)
Hope this helped!