Need help with coin system (Prompt not working)

So what I’m trying to achieve here is a coin system, everything is scripted and everything. The Coins are in the workspace Folder, and the value is in the Character. The issue here is that some of the proximity prompts don’t want to trigger the local Script for some reason under the GUI. When the prompt is triggered it shows the coin GUI and it gives the player a random amount of coins.

I have tried a couple of solutions so far, but none of them have worked. I’m pretty much at a halt and I’m not sure what to do anymore with it.

local Frame = script.Parent
local TS = game:GetService("TweenService")
local CoinFolder = game.Workspace.Money
local Player = game:GetService("Players").LocalPlayer
local Value = Player.Character:WaitForChild("Purse")
local Text = script.Parent.TextLabel
local MoneySound = script.MoneySOund
local RunService = game:GetService("RunService")

	for i, v in pairs(CoinFolder:GetDescendants()) do
		if v:IsA("ProximityPrompt") then
			v.Triggered:Connect(function()
				Frame:TweenPosition(UDim2.new(0.441, 0, 0.18, 0.0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2.5)
				Value.Value = Value.Value + math.random(2, 16)
				Text.Text = Value.Value
				MoneySound:Play()
				wait(4.5)
				Frame:TweenPosition(UDim2.new(0.441, 0, -0.52, 0.0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 2.5)
			end)
		end
	end

Try parenting the proximity prompt to the part itself

1 Like

this only work for coins that were added before this script started functioning if theres a spawning script for the coins. you can try to add a while() function for it to repeat get descendants of the coinfolder

Well, I didn’t add any spawning scripts to the coin. They’re just place anywhere around the map and the Player has to find them there. They don’t respawn as I’m trying to make them like the Mimics coin mechanic in Jealousy 2.

image
It already has been parented to the part itself, yet for some reason it unfortunately doesn’t want to work.

try adding a wait() before the whole script, that might work

1 Like

I’m assuming the ProximityPrompt is not working? I personally would use workspace:WaitForChild(“Money”), and I would add a print statement for each item found within the loop that is a ProximityPrompt, then printing a message if it does work.

1 Like

Already tried this, and it didn’t work for some reason. The proximity prompt works on some coins but on some others it doesn’t.

I already thought of that and did it, but unfortunately it didn’t work.

Are you sure that problem is in trigger? You tried to put print?

1 Like

Wait a second. I could be wrong and a idiot for this, but you should try looping through the children (the coins) then the children’s Descendants. This may work. Inside of your current code you’re just looping through all descendants, I think that may be causing issues.

1 Like

This is some bug I have also experienced when using proximity prompts. I am not sure it is fixable, but in my case, I had a lot of proximity prompts that it stopped working. This could also be your script.

1 Like

Yes, I’ve done that already but it refuses to work. I’m positive it’s a Roblox issue, it’s always making me think there’s something wrong with MY scripts especially when the console doesn’t show anything.

How would I do that? I’m not an expert at scripting, I started like a month or two ago and I’m starting out with really simple stuff.

Check if the Property called “StreamingEnabled” which is under workspace is set to true, if thats the case then this could cause the issue.

Consider disabling StreamingEnabled, since this is a localscript you will always get replication issues, which also causes why your code wont interfere with some of the prompts, well because Streaming doesnt immediately load all of the instances inside workspace, only those who are in your targeted streaming radius.

Hope this helped!

1 Like

Well, I have streaming enabled, except it’s range is pretty far to where things load. I’m making this game For my partner, and she can’t really play on a Computer. I’m not sure if her phone will be able to handle The game without it.

Like this:

local Frame = script.Parent
local TS = game:GetService("TweenService")
local CoinFolder = game.Workspace.Money
local Player = game:GetService("Players").LocalPlayer
local Value = Player.Character:WaitForChild("Purse")
local Text = script.Parent.TextLabel
local MoneySound = script.MoneySOund
local RunService = game:GetService("RunService")

	for i, v in pairs(CoinFolder:GetChildren()) do
            for _, x in pairs(v:GetChildren()) do
                   	if x:IsA("ProximityPrompt") then
			x.Triggered:Connect(function()
				Frame:TweenPosition(UDim2.new(0.441, 0, 0.18, 0.0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2.5)
				Value.Value = Value.Value + math.random(2, 16)
				Text.Text = Value.Value
				MoneySound:Play()
				wait(4.5)
				Frame:TweenPosition(UDim2.new(0.441, 0, -0.52, 0.0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 2.5)
			end)
		end
               end
	end
1 Like

Try to change ProximityPromptExclusivity to OneGlobally.

1 Like

Even if the range is pretty high , instance replication will never be instantly, meaningless we would need yields or other function connections which will handle new loaded prompts. I can provide you the script which could fix it without having to disable streamingenabled.

Edit:
Fixed spelling mistakes

I’ll see if this could work later today, I’m really hoping that it’s actually this instead of StreamingEnabled otherwise… I’ll have to play the game on 30 fps