Raycasting problem Position is not a valid member of Model "Workspace.WAHAHHAHAHAHH

LocalScript (StarterCharacterScripts)

local Player = game:GetService('Players').LocalPlayer

local Character = Player.Character
local RootPart = Character.HumanoidRootPart
local Mouse = Player:GetMouse()

local function CastARay()
	game.ReplicatedStorage.Shoot:FireServer(Player,Mouse,Character,RootPart)
	end

Script (ServerScriptService)

game.ReplicatedStorage.Shoot.OnServerEvent:Connect(function(Player,Mouse,Character,RootPart)
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {Character}


local Ray = workspace:Raycast(RootPart.Position , Mouse.Hit.p , Params)
if Ray then
		local obj = Ray.Instance
		print(obj.Name)
	end
	
end)

It Gives Position is not a valid member of Model "Workspace.Aqw1nss (comes from Script)

1 Like

You can’t get positions from models. Give the model a primary part and use Model.PrimaryPart.CFrame.

3 Likes