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)
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)
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.
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.
Insert a RemoteEvent into ReplicatedStorage, and name it VehicleSpawnerInteract
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)
Add the following Script, parented under your proximity prompt.
script.Parent.Triggered:Connect(function(plr)
game.ReplicatedStorage.VehicleSpawnerInteract:FireClient(plr)
end
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)