Proximity Prompts not working for unknown reason

Hey there! I’m trying to make a game, and I am trying to spread the different areas apart. For the plushie dispensers, I use a proximity prompt. These proximity prompts work at the spawn area, but do not work for the area just a little bit farther away from spawn, but when I use “Play Here” via studio, it works.

Here’s the code that doesn’t work.

script.Parent.Triggered:Connect(function(player)
local tool = game.ReplicatedStorage.MetalNoob
local backpack = player:FindFirstChild(“Backpack”)
if backpack then
tool:Clone().Parent = backpack
tool.Value.Value = math.random(4000, 6900)
end
end)

Here’s the one that does work

script.Parent.Triggered:Connect(function(player)
	local tool = game.ReplicatedStorage.ProNoob
	local backpack = player:FindFirstChild("Backpack")
	if backpack then
		tool:Clone().Parent = backpack
		tool.Value.Value = math.random(5000,10000)
	end
end)

as you can see, it is almost the same script. What can cause this? I suspect it is that the proximity prompt isn’t loaded in the server yet.

here’s a short video

It’s because you were using some sort of different comma stuff for the broken one. Here’s the fixed version:

If you see red lines in your script, it probably means theres an error.

It was simply because of a mistype.

script.Parent.Triggered:Connect(function(player)
	local tool = game.ReplicatedStorage.MetalNoob
	local backpack = player:FindFirstChild("Backpack")
	
	if backpack then
		tool:Clone().Parent = backpack
		tool.Value.Value = math.random(4000, 6900)
	end
end)

you are cloning the tool, but you arent using the cloned version to set the value.

local clonedTool = tool:Clone()
clonedTool.Parent = backpack
clonedTool.Value.Value = math.random(5000,10000)

i think is the code you intended on doing

also there is no need to find the Backpack inside the player, as long it isnt destroyed in some weird edge case.

Hey there! Just tried this, it didn’t work for me.

This still didn’t work. I don’t think it’s that. There were no red lines in the first place.