Issue With Timed Bar

I need to make it so if the player times it incorrectly it dosent error out. Error occurs at line 110 “Positon is not a valid member of Frame” This only happens when I time it incorrectly, If it time it good then it works as normal, I thought the “else” put at line 115 would do it but apparently not

game.ReplicatedStorage.FightingEvents.KnockdownGui.OnClientEvent:Connect(function(player, Difficulty)
	
	--TweenInformation
	local TimerBar = Players.LocalPlayer.PlayerGui.FightingHud.Knockdown.Ticker
	local SpotToHitFrame = Players.LocalPlayer.PlayerGui.FightingHud.Knockdown.SpotToHit
	local TweenTime = nil
	local StartHit = UDim2.new(0.426, 0, 0, 0)
	local EndHit = UDim2.new(0.526, 0 , 0, 0)
	Knockdown = true
	
	if Difficulty == 1 then
		TweenTime = 1
	end
	
	if Difficulty == 2 then
		TweenTime = 2
	end
	
	if Difficulty == 3 then
		TweenTime = 3
	end

	local KnockTimerGoals = {}
	KnockTimerGoals.Position = UDim2.new(1, 0 , 0, 0)
	
	wait(1)
	
	local tweenInfo = TweenInfo.new(
		0.5, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		true, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)
	
		 
	local KnockTimerTween = TweenService:Create(TimerBar, tweenInfo, KnockTimerGoals)
	
		 
	KnockTimerTween:Play()
	
	UserInputService.InputBegan:Connect(function(input, event)
		if input.KeyCode == Enum.KeyCode.Space and Knockdown == true and event == false and KnockTimePressed == false then
			KnockTimePressed = true
			KnockTimerTween:Pause()
				if TimerBar.Position.X.Scale >= StartHit.X.Scale or TimerBar.Positon.X.Scale <= EndHit.X.Scale then
				print("TimedCorrectly")
				TimerBar.Position = UDim2.new(0, 0, 0, 0)
				wait(1)
				KnockTimePressed = false
			else
				print("TimedBadly")
				TimerBar.Position = UDim2.new(0, 0, 0, 0)
				KnockTimerTween:Play()
				wait(1)
				KnockTimePressed = false
			end
		end	
	end)
end)

Which line is 110 ? :thinking:

1 Like

Judging by the error, it seems to be a spelling error that causes this.

if TimerBar.Position.X.Scale >= StartHit.X.Scale or TimerBar.Positon.X.Scale <= EndHit.X.Scale then

I think i found the error
Spelling is wrong

The second word position is spelt wrongly

I can confirm its not a spelling error because it works when i get it within the starthit and endhit it works fine

You forgot to put a i in the word position on line possibly 110 the second one

But its still spelled wrong, so it should be fixed, should it not?
Unless that was intentional.

OH, ok I see what you were saying, I changed it and the error is gone, but even still when I time it wrong it dosen’t work properly. I’ll gif it real quick.

https://gyazo.com/af90ae430dfb5db9b236cffe753b83d7

Heres a gif of it, and heres the output.


https://gyazo.com/1e0eabad318415768b9217688669ba82

As you can see I was way off but i still got the “Timed Correctly” Print MSG

I don’t quite know why it won’t work, but one thing I would do is print both TimerBar.Position.X.Scale and StartHit.X.Scale to make sure the results are accurate.

Ok I realized that instead of instead of putting “and” I put “Or”, thanks for your help tho!

No problem, just glad to help!