local RS = game:GetService("ReplicatedStorage")
local Event = RS.KeyPressed
local db = false
Event.OnServerEvent:Connect(function(player, Key)
local Humanoid = player.Character.Humanoid
if db == false then
db = true
if Humanoid.Health > 0 then
local HRP = player.Character.HumanoidRootPart
if Key == "Right" then
if HRP.Position.X == -8 then
print("BRUH")
else
HRP.CFrame = HRP.CFrame + Vector3.new(-10,0,0)
end
elseif Key == "Left" then
HRP.CFrame = HRP.CFrame + Vector3.new(10,0,0)
elseif Key == "Down" then
end
end
end
wait(.2)
db = false
end)
Moves the player 10 studs left and right depending on the key they press, and I want to set a limit on how far they can go, so I made an if statement saying this if they are on 8 on the X axis they cannot move that certain way, but although the player will always be on the 8 on the X axis at one point, it isnt going to be exact, maybe it is 8.1092 or 8.93, but never just 8, so how would I check for anything on the 8 on the X axis but not super exact.
Just printing BRUH only tells you if the condition is met. It doesn’t tell you why.
Try troubleshooting this way:
print(HRP.Position.X) --to see what the actual value is.
if math.round(HRP.Position.X) < 8 then -- only allows the CFrame to work if the X position is less than the limit of 8
HRP.CFrame = HRP.CFrame + Vector3.new(-10,0,0)
end
[/quote]
Now, are you trying to count 8 10 stud movements, or you just want the player to only get to a certain X Position in the World Space?