Proximity Prompts Being Funky

Ello! For whatever reason, I can edit this script into a local or server script, it refuses to work. I don’t see any errors, and the code looks similar to working code I used for the same exact thing about a year ago. Anyone can help? Thanks!

-- Local Script
script.Parent["Vehicle Spawner"].Triggered:Connect(function()
	local Playergui = game.Players.LocalPlayer.PlayerGui
	local CarSpawnerUI = Playergui:WaitForChild("car spawn")
	
	Playergui["car spawn"].Enabled = true
	
	if script.Parent["Vehicle Spawner"].Triggered and Playergui["car spawn"].Enabled = true then
		print("It worked!")
	else
		warn("SpawnCarGUI has failed to open with proximity prompt.")
	end
end)
2 Likes

Shouldn’t Playergui["car spawn"].Enabled = true be Playergui["car spawn"].Enabled = true?
Also Triggered is an event.

script.Parent["Vehicle Spawner"].Triggered:Connect(function()
    if Playergui["car spawn"].Enabled == true then
        print("It worked!")
    else
        warn("SpawnCarGUI has failed to open with proximity prompt.")
    end
end)

Your code should be this:

-- Local Script
script.Parent["Vehicle Spawner"].Triggered:Connect(function()
	local Playergui = game.Players.LocalPlayer.PlayerGui
	local CarSpawnerUI = Playergui:WaitForChild("car spawn")
	
	Playergui["car spawn"].Enabled = true
	
	script.Parent["Vehicle Spawner"].Triggered:Connect(function()
        if Playergui["car spawn"].Enabled == true then
            print("It worked!")
        else
            warn("SpawnCarGUI has failed to open with proximity prompt.")
        end
    end)
end)
1 Like

oops forgot to add Triggered event

Yeah, doesn’t work for whatever reason.
Really confused.

Also, that print and warn statement is just to verify that it actually worked but for some reason it doesn’t even print to the output. I’m starting to wonder if this is a studio issue.

Sorry, I forgot to edit it. The code should be this:

-- Local Script
script.Parent["Vehicle Spawner"].Triggered:Connect(function()
	local Playergui = game.Players.LocalPlayer.PlayerGui
	local CarSpawnerUI = Playergui:WaitForChild("car spawn")
	
	Playergui["car spawn"].Enabled = true
	
	script.Parent["Vehicle Spawner"].Triggered:Connect(function()
        if Playergui["car spawn"].Enabled == true then
            print("It worked!")
        else
            warn("SpawnCarGUI has failed to open with proximity prompt.")
        end
    end)
end)

Edit: Also, in the future, I recommend using something:WaitForChild("WHATEVER") instead of something["WHATEVER"]. WaitForChild is better to use as something may not load properly.

Also, proximity prompt is best handled on the server.

Doesn’t work.

That if statement aka this

	script.Parent["Vehicle Spawner"].Triggered:Connect(function()
        if Playergui["car spawn"].Enabled == true then
            print("It worked!")
        else
            warn("SpawnCarGUI has failed to open with proximity prompt.")
        end

is just to check that it actually works. It doesn’t even print to the output. The thing that I want it to do is to make the CarSpawn GUI to become visible. This is the line of code I think is having the issues.

	Playergui:WaitForChild("car spawn").Enabled = true -- Main problem I think is being caused here.

Is script.Parent["Vehicle Spawner"] a proximity prompt?

VehicleSpawner is a proximity prompt, correct.

edit: just changed it to a serverscript, same conclusion.

  1. Insert a RemoteEvent into ReplicatedStorage, and name it VehicleSpawnerInteract
  2. Replace the LocalScript with the following.
local LocalPlayer = game.Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:WaitForChild("car spawn").Enabled = true
game.ReplicatedStorage.VehicleSpawnerInteract.OnClientEvent:Connect(function()
    if PlayerGui:FindFirstChild("car spawn").Enabled == true then
        print("It worked!")
    else
        warn("SpawnCarGUI has failed to open with proximity prompt.")
    end
end)
  1. Add the following Script, parented under your proximity prompt.
script.Parent.Triggered:Connect(function(plr)
    game.ReplicatedStorage.VehicleSpawnerInteract:FireClient(plr)
end

Doesn’t work. I’ll go try to publish it and test it out of studio.

Still getting nothing in the output by pressing F9, and it isn’t working. I really wonder what isn’t working…

??? that code doesnt even make sense, what are you even trying to do here

judging by the way your original code was written, it seems like you had a local script in workspace, which will not run

instead, please try replacing the local script (if it is in workspace) with this SERVER script

script.Parent["Vehicle Spawner"].Triggered:Connect(function(player)
	local Playergui = player.PlayerGui
	local CarSpawnerUI = Playergui:WaitForChild("car spawn")
	
	Playergui["car spawn"].Enabled = true
	
	if Playergui["car spawn"].Enabled then
		print("It worked!")
	else
		print("SpawnCarGUI has failed to open with proximity prompt.")
	end
end)

you don’t even make sense, how do you not know what RemoteEvents are?

i was replying to your original message, i also do know what remote events are lmao

your original code didnt even make sense, you were nesting events for no reason

oh i made a mistake

character limit

also please dont be unnecessarily toxic

thats not even being toxic, what do you mean being toxic

just want to point out, the documentation for proximity prompts is just a quick google search away

(for future needs)