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

How do you disable the visibility of the prompt locally when the player is seated?

Asked by 3 years ago
Edited 3 years ago

I tried to add more seats to my vehicle and the fact that CanCollide is enabled, I have to use ProximityPrompts. Problem is that when I take a seat, the prompts of the other seats show up and I tried to disable it locally. But my code didn't work since I don't know how events work. There was another solution by getting all children and make Instance.Enabled false, but I don't know how to make it do so.

LocalScript code:

local promptService = game:GetService("ProximityPromptService")
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

function onSeated(isSeated, seat)
    if isSeated then
        promptService.PromptHidden = true
    else
        promptService.PromptHidden = false
    end
end
humanoid.Seated:Connect(onSeated)

1 answer

Log in to vote
1
Answered by 3 years ago

I think this should work. Your code didn't work because PromptHidden is an Event.

Place this LocalScript in StarterCharacterScripts

local promptService = game:GetService("ProximityPromptService")
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

function onSeated(isSeated, seat)
    if isSeated then
        promptService.Enabled = true
    else
        promptService.Enabled = false
    end
end
humanoid.Seated:Connect(onSeated)
0
It didn't work... Gam3r_Play3r 47 — 3y
0
changed my mind, I managed to fix it Gam3r_Play3r 47 — 3y
0
No problem SpectacularPavlos 86 — 3y
Ad

Answer this question