Hello, I am looking to create an aircraft, where the pilot seat would be entered with a Proximity Prompt. I wish for the proximity prompt to only be usable by the owner (determined by stringvalue), and not allow anyone with a different username to use the seat.
Currently, the prompt can be used by anyone, regardless of whether or not they are the owner
So far, I have this script:
local ProximityPrompt = script.Parent
local seat = ProximityPrompt.Parent
local owner = game.Workspace.OwnerValue.Value
seat.Disabled = true
ProximityPrompt.RequiresLineOfSight = false
ProximityPrompt.Triggered:Connect(function(player)
seat.Disabled = false
local charecter = workspace:WaitForChild(player.Name)
if player.Name == owner then
local humanoid = charecter.Humanoid
seat:Sit(humanoid)
ProximityPrompt.Enabled = false
while seat.Occupant do
wait()
end
else
ProximityPrompt.Enabled = true
seat.Disabled = true
end
ProximityPrompt.Enabled = true
seat.Disabled = true
end)
I searched through about two dozen other posts and solutions on here, however none seem to work. Thank you.
i assume he is using an id to determine if hes the owner.
i recommend trying
ProximityPrompt.Triggered:Connect(function(player)
local owner = game.Workspace.OwnerValue.Value
if owner then
print("Owner: " .. owner)
else
print("Owner not found")
return
end
Tested this system with both Owner ID and Username. It prints the value of the string value, but does not determine whether or not the owner was the one interacting with the prompt.
I edited some things in the script. Check if this works:
local Game_Workspace = game:GetService("Workspace")
local ProximityPrompt = script.Parent
local Seat = ProximityPrompt.Parent
local Owner = Game_Workspace:WaitForChild("OwnerValue")
ProximityPrompt.RequiresLineOfSight = false
Seat.Disabled = true
ProximityPrompt.Triggered:Connect(function(player)
Seat.Disabled = false
local character = Game_Workspace:FindFirstChild(player.Name)
if player.Name == Owner.Value then
local humanoid = character.Humanoid
Seat:Sit(humanoid)
ProximityPrompt.Enabled = false
while Seat.Occupant do
task.wait()
end
else
ProximityPrompt.Enabled = true
Seat.Disabled = true
end
ProximityPrompt.Enabled = true
Seat.Disabled = true
end)
Tried this script, however it does not recognize anyone as the owner at all. I added a print function to your script, and it keeps returning “Not Owner”.
local Game_Workspace = game:GetService("Workspace")
local ProximityPrompt = script.Parent
local Seat = ProximityPrompt.Parent
local Owner = Game_Workspace:WaitForChild("OwnerValue")
ProximityPrompt.RequiresLineOfSight = false
Seat.Disabled = true
ProximityPrompt.Triggered:Connect(function(player)
Seat.Disabled = false
local character = Game_Workspace:FindFirstChild(player.Name)
if player.Name == Owner.Value then
print("Owner")
local humanoid = character.Humanoid
Seat:Sit(humanoid)
ProximityPrompt.Enabled = false
while Seat.Occupant do
task.wait()
end
else
print("Not Owner")
ProximityPrompt.Enabled = true
Seat.Disabled = true
end
ProximityPrompt.Enabled = true
Seat.Disabled = true
end)
Sorry for the trouble, the reason for your script not working was due to me accidentally misplacing it. The current system is functional, Thank you for your help!