Problem with finding if then

So this script i made reads a bool value that is set true by another local script. whats odd is that whenever this bool value is true in the output theres an error either:

  • aiming isnt a valid member of tool
  • script cannot find firstpersonarms

This means whenever the script is applied it wont change the Y value which is a huge problem

local Player = game.Players.LocalPlayer
local AIMING = script.Parent.Aiming

if AIMING.Value == true then
	Player.PlayerGui["FirstPersonArms"].LERP.Y.Value = -1.2
else
	Player.PlayerGui["FirstPersonArms"].LERP.Y.Value = -1
end

Any help would be nice, thanks!

1 Like

Can you send a screenshot of what is inside the starter gui and what is in the script parent?

1 Like

From the code you have given, that script will only run once. If you want it to detect whenever the bool value has changed and check if AIMING.Value = true then you should put it inside a while true do statement or put it inside a function that is triggered using GetPropertyChangedSignal or Changed

(This may or may not be useless because I am slightly confused at what you need help with)

Sorry im very vague at explaining this kind of stuff, ill try this out

1 Like

I would also recommend using

local Player = game.Players.LocalPlayer
local AIMING = script.Parent:WaitForChild("Aiming")
AIMING.Changed:Connect(function()
if AIMING.Value == true then
	Player.PlayerGui:WaitForChild("FirstPersonArms").LERP.Y.Value = -1.2
else
Player.PlayerGui:WaitForChild("FirstPersonArms").LERP.Y.Value = -1
end
end)
2 Likes

Only think I could think of making it an elseif statement (prob would make the script worse but worth a try)
replacing else with elseif

Ah yes, WaitForChild fixes the “script cannot find firstpersonarms” problem.

This script is suppose to check if a bool value is set true via another script activating this bool value and if it isnt the LERP is suppose to go back to -1

1 Like

Use the new script I sent, I was fixing it I think it should work

1 Like

Ive tried that thats the issue yet its still the aiming is not a valid member of tools

You should try what @DeepBIake sent above. I believe it is the solution!

Send a screenshot of what is inside the scripts parent

Ive tried it just now it just does nothing now lol could i try Aiming.Value.Changed?

What do you mean by nothing? Aaaaaaaa

Is this particular script inside “tool” and does “tool” have a child called “Aiming”?

The tool has a the aiming bool value in it, (this is a local script btw)

This doesn’t work, keep in mind this is in a local script so anything that is changed here will not be effected to the server

Whats weird is that if i add something stupid like this

local Player = game.Players.LocalPlayer
local AIMING = script.Parent.Aiming

script.Enabled = false
wait()
script.Enabled = true

if AIMING.Value == true then
	Player.PlayerGui["FirstPersonArms(R6)"].LERP.Y.Value = -1.2
else
	Player.PlayerGui["FirstPersonArms(R6)"].LERP.Y.Value = -1
end

it starts working

i took turning it off then turning it back on literally and it works idk how but it seems super unreliable

1 Like

You do realize that the name you put in there is different from what it was before right

FirstPersonArms → FirstPersonArms(R6)

1 Like

Wdym??