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)