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

2 Likes

Try parenting the proximity prompt to the part itself

2 Likes

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

1 Like

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.

1 Like

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

1 Like

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

2 Likes

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.

2 Likes

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.

1 Like

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

1 Like

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

2 Likes

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.

2 Likes

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.

2 Likes

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.

1 Like

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.

1 Like

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!

2 Likes

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.

1 Like

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
2 Likes

Try to change ProximityPromptExclusivity to OneGlobally.

2 Likes

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