Hello! i am making a jojo game and i am trying to make a time skip move. To make the player not able to teleport through walls (this is my first time trying to cast a raycast) i tried raycast method and the error is "Unable to cast CoordinateCFrame to Vector3" Heres the script:

local ReplicatedStorage = game:GetService("ReplicatedStorage") 
local remoteEvent = ReplicatedStorage:WaitForChild("Stand1"):WaitForChild("Teleport")
local ServerStorage = game:GetService("ServerStorage")
local Workspace = game:GetService("Workspace")
local dmg = 12
local TookDmg = false
local attackAnim = script:FindFirstChild("attack")

function onServerEvent(player)
	local rayOrigin = player.Character.HumanoidRootPart.CFrame
	local rayDirection = player.Character.HumanoidRootPart.CFrame*CFrame.new(0, 0, -30)*CFrame.Angles(math.rad(0),0,0)
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {player.Character.HumanoidRootPart.Parent}
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
	if raycastResult then
	player.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame*CFrame.new(0, 0, -30)*CFrame.Angles(math.rad(0),0,0)
	print(3+6)

	end    
	end



	remoteEvent.OnServerEvent:Connect(onServerEvent)



Help appreciated!

2 comments

0

:Raycast takes 2 vectors, not 2 CFrames, rayOrigin should be RootPart.Position and rayDirection should be RootPart.Position + Vector3.new(0, 0, -30) i think.

0

i already did that it still doesn't work