Bool isn't working correctly

So I’m planning on making a detection script but theirs a problem with the bool value. I have it set up we’re if the bool is true the platformstand in the character is triggered. But nothing is happenening when I true the value. Please help.

local Character = script.Parent

local Humanoid = Character.Humanoid

local RootPart = Character.HumanoidRootPart

local Value = script.onGround

Value.Changed:Connect(function()

if Value then Humanoid.PlatformStand = true else Humanoid.PlatformStand = false end

end)
2 Likes
local Value = script.onGround.Value

You forgot to add .Value to ur variable.

1 Like

This wouldn’t fix his solution because the Value variable is meant to reference the actual ValueBase object (you can assume that because the next line is Value.Changed)

Try this instead:

local Character = script.Parent
local Humanoid = Character.Humanoid
local RootPart = Character.HumanoidRootPart

local onGround = script.onGround
onGround.Changed:Connect(function(newValue)
    if newValue then
        Humanoid.PlatformStand = true
    else
        Humanoid.PlatformStand = false
    end
end)

Edit: You can actually optimize this because of how you’re using the onGround bool. The function could just be this:

onGround.Changed:Connect(function(newValue)
    Humanoid.PlatformStand = newValue
end)

Ohhh my bad, i shud prob read the whole script in such cases. So @anxlr ur solution is @NoParameters post. The reason is because ur checking the original value not the changed one.

For some reason it didn’t work I’m checking and unchecking the value but the player is still up

Are you changing the bool value on the server or the client?

I’m changing the bool on a client

Try this:

local Character = script.Parent

local Humanoid = Character.Humanoid

local RootPart = Character.HumanoidRootPart

local Value = script.onGround

Value.Changed:Connect(function()
Humanoid.PlatformStand = Value.Value -- Adding a property to read the value. Should work assuming that you synchronize values. 
end)
1 Like

Try changing it on the server and see if that alters the result. After hitting play solo, go to HomeTest and click "Current: Client" to switch it over to the Server. Then, try changing the bool value.

Local scripts will detect changes brought to the player by both local and server scripts, this does not matter as long as a local script is used.

Those 2 suggestions didn’t seem to work either

Are there any errors in the output?

Okay so it says that. The value isn’t being found inside the script

Where did you parent the onGround BoolValue to? A picture of the explorer would be useful.

I meant it isn’t being detected as a child inside the script*

Potential solution:

Place a value in the character, not in the script, and bring proper changes.

All I did was do this.

local Character = script.Parent

local Humanoid = Character.Humanoid

local RootPart = Character.HumanoidRootPart

local Value = script:WaitForChild('onGround')

Value.Changed:Connect(function()
	Humanoid.PlatformStand = Value.Value -- Adding a property to read the value. Should work assuming that you synchronize values. 
end)

All of a sudden it works now. It does it job correctly

Ah, well, yeah, I forgot about :WaitForChild as a way out.

2 Likes