I am currently working on a vehicle spawning system for my new game. All is working well, except that it doesn’t actually spawn anything, and I am getting absolutely no feedback from the output.
Basically, the way this system is supposed to work, is based on a LocalScript that manages player interaction with an NPC. Script detects when an NPC has been added to someone’s base, and the script handles interactions with player, like having the NPC wave at the player when a ProximityPrompt within the NPC is visible to the local player etc., and when the local player triggers the ProximityPrompt, the local script will open up the vehicle selection UI + change a value within said UI that is the remote, that when fired, will spawn the vehicle.
Here’s the relevant NPC code:
game.Workspace.tycoons.DescendantAdded:Connect(function(child)
if child.Name == "vehicleSpawnNPC" then
local data = {plrNear = false,dummy = child}
chars[child] = data
local head = child:WaitForChild("Head",10)
local prox = head:WaitForChild("ProximityPrompt",3)
if prox ~= nil then
local playIt = child.Humanoid:LoadAnimation(animation)
prox.PromptShown:Connect(function()
chars[child].plrNear = true
playIt:Play()
playIt.Looped = true
prox.PromptHidden:Wait()
chars[child].plrNear = false
playIt:Stop()
end)
prox.Triggered:Connect(function(player)
print("success on the NPC")
if player.PlayerGui.vehicleSelector.Enabled == false then
player.PlayerGui.vehicleSelector.remoteLocation.Value = child:WaitForChild("remoteLocation",3).Value
player.PlayerGui.vehicleSelector:SetAttribute("Type",child:GetAttribute("type"))
player.PlayerGui.vehicleSelector.Enabled = true
end
end)
end
end
end)
and here is the relevant code for the vehicle spawning UI:
spawnButton.MouseButton1Down:Connect(function()
if selectedVehicle ~= nil and script.Parent.remoteLocation.Value ~= nil then
print("success on the UI click working")
local remote = script.Parent.remoteLocation.Value
remote:FireServer(selectedVehicle)
end
end)
These scripts will both print the print statements that I have included in them. However, the print statement I have within a server script when the remote is fired by the above code never executes, and a vehicle is never spawned.
I have spent the last 2 or so hours trying a variety of ways to fix this, and absolutely nothing has fixed it. I have no idea what I am doing wrong.