Script Not Detecting value change

"Hello, I am new to scripting and require assistance with this Lua script:

local ProximityPrompt = script.Parent.Place

ProximityPrompt.Triggered:Connect(function(Player)
	local Character = Player.Character
	if script.Value.Value == 6 then
		workspace.Sounds["PlaceItem"]:Play()
		script.Parent.Parent.Model.Sword.Transparency = 0
		script.Parent.Build.Enabled = true
		ProximityPrompt:Destroy()
		script:Destroy()
	else
		game.ReplicatedStorage.PartsNeeded:FireClient(Player)
	end
end)

The script does not detect when the value changes to 6 during gameplay. Initially starting at 0, if the value changes to 6 while the game is running, the script fails to recognize this change and triggers the not intended event."

I am unsure if this is the answer you are looking for, but here’s what I think. You say that the script doesn’t detect the value change. This script is not going to always work because the event only triggers when the proximity prompt gets triggered. That means that this script is only going to check if the value is equal to six when you trigger the prox prompt. If this isn’t the right answer, please just provide more info and i’ll look into it.

2 Likes

I understand that the script checks the value only when the proximity prompt is triggered. However, even after verifying that the value is 6, the script still does not work and it fires the “PartsNeeded” event.

Are you changing the value on the server or the client while running the game?

1 Like

Im changing in the server
image

I didn’t mean like that
When you are testing, there is a button on the top called “Current-Client”. When you change the value, is that button set to “Current-Server”?

1 Like

I change the value in Current Client

Thats the problem.
Server doesnt see Client changes.
You are running a Server script that checks on that value, However as I said before, for server that value is still Zero

1 Like

It won’t work like that as a server script can’t detect a value change on the client, click the button to “Current-Server” and then change it

1 Like

Oh now I understand. It worked now thank you

That was the problem now I fixed it thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.