ErrorType: Syntax
if Statement With Operator
In an 'if' statement, you must have '==' if you want a value equal to another value. But in your case, use '<=' to find see if the velocity is less than or equal to the value.
if game.Workspace.Humanoid.Torso.Velocity <= Vector3.new(0,-210,0) then
The way you had set up your 'if' statement can be wonky, as the format looks like this:
if game.Workspace.Humanoid.Torso.Velocity <= Vector3.new(0,-210,0) then
game.Players.LocalPlayer.PlayerGui.BlackoutGUI.Frame.Visible = true
if game.Workspace.Humanoid.Torso.Velocity >= Vector3.new(0,-209,0) then
game.Players.LocalPlayer.PlayerGui.BlackoutGUI.Frame.Visible = false
end
end
if Statements
If the velocity is (0,-210,0), then there is no way that the second 'if' statement will run.
Separate your 'if' statements.
if game.Workspace.Humanoid.Torso.Velocity <= Vector3.new(0,-210,0) then
game.Players.LocalPlayer.PlayerGui.BlackoutGUI.Frame.Visible = true
end
if game.Workspace.Humanoid.Torso.Velocity >= Vector3.new(0,-209,0) then
game.Players.LocalPlayer.PlayerGui.BlackoutGUI.Frame.Visible = false
end
ErrorType: Logic
New/ Forgotten Materials
Since you probably would want the script to check the torso's velocity all the time, you will want to place the script in a 'while' loop.
s = script.Parent
while true do
if game.Workspace.Humanoid.Torso.Velocity <= Vector3.new(0,-210,0) then
game.Players.LocalPlayer.PlayerGui.BlackoutGUI.Frame.Visible = true
else
game.Players.LocalPlayer.PlayerGui.BlackoutGUI.Frame.Visible = false
end
wait(.1)
end
Unintended Error
game.Workspace.Humanoid.Torso... indicates that if the 'Humanoid' object in 'Workspace' specifically has a velocity of (0,-210,0). This means that all of the players' BlackoutGUI will be visible, which is kind of flawed if other players aren't in the same plane.
if game.Players.LocalPlayer.Character:FindFirstChild("Torso").Velocity == Vector3.new(0,-210,0) then
Vector3 - Velocity
There's another problem. The above is saying that if the Torso has a velocity of (0,-210,0) and only (0,-210,0), then the GUI will be visible. Unfortunately, if it's not, then as indicated by 'else' (or your extra 'if' statement), the GUI will become invisible.
How is this a problem? Well, for one, your plane will move forward (more or less), which makes your Torso's velocity have the x- and/or z-axes higher/lower than 0. To solve this problem:
local CurrentXValue = game.Workspace.Humanoid.Torso.Velocity.x
local CurrentZValue = game.Workspace.Humanoid.Torso.Velocity.x
if game.Players.LocalPlayer.Character:FindFirstChild("Torso").Velocity <= Vector3.new(CurrentXValue,-210,CurrentZValue) then
4 comments
You need two equal signs look at my answer.
==(line 4)
@dragonmaster4111 why did you Open a Claim and said this post is a spam?
@dragon this is not a spam post