i'm making a little game to test stuff, and for one of these i have to fire an "all clients" remote event, the event is fired if a spring is within a certain length (sort of to detect the distance between the player and a certain attachment i put, which is meant to be a win platform (i can't just use an "ontouched" function because you also need to be standing still, and with my knowledge, it's better if i do this instead

i tried using a "changed" function on the spring, but nothing worked, so i had to use a while true do loop on a 0.1 wait (to keep it as little delay as possible without being too much)

this is the code sample that's erroring

while true do
	local length = script.Parent.SpringConstraint.CurrentLength
	
	if length <= 7 and script.Parent.Velocity.Magnitude <= 1 then
		workspace.Cones.Script.Disabled = false
		print("winned")
		script.fire.Disabled = false
		script.Disabled = true
	end
	wait(0.1)
	end

the "fire" script is something i'm using to fire the event, since i thought that since the event was fired on a loop, that was causing the problem, but it wasn't

the fire script just has this code

workspace.WinEvent:FireAllClients()

if anyone can help me with fixing this, it would be much appreciated.

3 comments

0

what is CurrentLength, an intValue you placed in SpringConstraint?

0

also can you tell me what the error is saying?

0

CurrentLength is a property for SpringConstraints, the error is just "attempt to call a nil value", then is keeps printing "winned" without ever firing the event