Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My intvalue if statement is not working correctly?

So im trying to make a FNaF movement but with a flash mechanic which makes the character go 1 step back

I have a IntValue for the position, after the script sleeps for some random time generated, the IntValue increments by 1, the script that moves the model and does all that visual n sound effect things, will just execute when the IntValue is incremented

In resume: I have the intvalue incremented by 1 so the character moves 1 step forward the player uses the flash mechanic and the intvalue decrements by 1, but when that is made, the character will not move 1 step back

the script is a basic one but it should, on my believings work

Value.Changed:Connect(function()
	if Value.Value == 1 then
		model:SetPrimaryPartCFrame(position1)
	end
	if Value.Value == 2 then
		model:SetPrimaryPartCFrame(position2)
	end
	if Value.Value == 3 then
		model:SetPrimaryPartCFrame(position3)
	end
end)

i have those variables defined, it is just a how it looks like.

Any idea to whats wrong??

2 comments

0

SetPrimaryPartCFrame()* not lowercase s

0

I know, made a mistake there

1 answer

✓ Accepted answer

Hey there! So I think what's happening is when your setting it back for E.G from 3 to 2 when checking what value the intvalue is when your setting the primarypartcframe position the position that is being changed is still the position that makes the character go forward.

Not sure if that made sense but hopefully it did!

This discussion is preserved as it was. New answers, comments, and votes are closed.