Local script working in one place, and not the other

Hey guys, today I was working on a simple local script, which is supposed to change the volume of a sound object to 1, when you trigger a prompt (The local script is in StarterPlayerScripts). However, when I went ahead and tested it, the code did not work. At first I assumed that I made a mistake, since this was not an uncommon scenario for me, but after a couple minutes of troubleshooting, I realised that something was not right. So what I decided to try the same exact thing in another place, a fresh new place, only to discover that the same exact script worked… perfectly!? I was beyond confused about what I’ve just observed, and so, I am now here in the dev forum after checking every other script within that first place, to make sure nothing is causing this issue, to ask you guys for your opinions on this situation.

Heres the code that I’ve used to confirm my suspicions in the first place:

local Prompt = game.Workspace:WaitForChild("Part").Prompt

Prompt.Triggered:Connect(function()
	print("WHY WONT YOU WORRRRK!")
end)

and then here is the code in the new place

local prompt = game.Workspace:WaitForChild("Part").ProximityPrompt
local sound = game.Workspace["where feelings go to die"] -- random sound to test

prompt.Triggered:Connect(function()
	sound.Volume = 5
	print("Soundplaying")
end)

The first script was after testing this code in the new place, yk to ensure that the local script really isn’t working.

And here are pictures of the locations of each object:

First place (or og place)

image

image

Second place

image

image

2 Likes

The prompt may not be streamed to the client properly which I dont think is the issue here since you have to approach it, is there any other script you have other than that local script. Make sure your part is Anchored properly, any other script you have may also be affecting this.

2 Likes

No, just this one, this has never happened to me before, until recently. And yea all the parts are anchored

1 Like

Are you sure that no other script affects this? Also you should add WaitForChild for the prompt aswell, you can also try making the part a module and setting ModelStreamingMode to persistent but what is probably happening here is it is either detecting another part (added by one of the other scripts) or you are not waiting properly for the prompt to load in.

2 Likes

Alright wait, i will try adding waits to this thing to see what happens. But this doesn’t explain why in the other place, the script worked fine.

1 Like

The other place probably has nothing to load so it may be loading the ProximityPrompt before the client can initiate. However on your main place it may take a while to load everything which can cause the proximity to load after the client has already initiated.

Ah I just realized, are the proximity names correct in your script?

2 Likes

Ok so you were right about the prompt needing a wait. Similarly, you were right about the sound object being manipulated in another script. I’ll have to find this bug and squish it. Thanks man!

edit: strangely enough, the sound object that wasn’t changing seemed to not be connected to any code, since i decided to change its name in order for the “script” to freakout and give me an error, but it didnt… This is one strange occurrence.

2 Likes