Raycast isn't working properly

  1. What do you want to achieve? Keep it simple and clear!
    So i want to make a raycast that fires each time you hit punch (m1), and if the ray doesn’t detect anything, it will set a downslamstate value to true, which will enable you to downslam an opponent.

  2. What is the issue? Include screenshots / videos if possible!
    Issue is, its like the ray origin position doesnt change when i run it, its hard to explain but heres a video:

task.spawn(function()
		local rayResult = workspace:Raycast(RootPart.CFrame.Position, -(RootPart.CFrame.UpVector.Unit * 6.5), downSlamParams)

		if not rayResult then
			if not DownslamState[userId] then
				DownslamState[userId] = true
			end

			clientFX:FireClient(Player, "LoadAnim", {Animation = repStorage.Animations.DefaultFist.Downslam})
		else
			DownslamState[userId] = false
		end
	end)

First time trying to time the downslam:

Your if statement is structured wrong. Your direction value is also wrong, you don’t need the .Unit vector.

Code:

task.spawn(function()
		local rayResult = workspace:Raycast(RootPart.CFrame.Position, -(RootPart.CFrame.UpVector * 6.5), downSlamParams)

		if rayResult then
			DownslamState[userId] = true

			clientFX:FireClient(Player, "LoadAnim", {Animation = repStorage.Animations.DefaultFist.Downslam})
		else
			DownslamState[userId] = false
		end
	end)

No, i don’t think it is wrong, because i just did it on the client and it works. It seems as if it was server delay. Also, im detecting if there is no raycast, which means the character is in the air. If it does detect a raycast, then im at the ground and it will not do a downslam.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.