Hello Everyone.
Following AlvinBlox’s tutorial on Make a GUN in Roblox in 10 minutes - YouTube I keep getting the error:
19:16:44.166 Unable to cast value to Objects - Server - Server:4
This is my current code exactly like the code in the video:
script.Parent.Fire.OnServerEvent:Connect(function(player, mousePos)
local RayCastParams = RaycastParams.new()
RayCastParams.FilterDescendantsInstances = (player.Character)
RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
local RayCastResults = workspace:Raycast(script.Parent.Handle.Position, (mousePos - script.Parent.Handle.Position * 300), RayCastParams)
if RayCastResults then
local HitPart = RayCastResults.Instance
local Model = HitPart.FindFirstAncestorOfClass("Model")
if Model then
if Model.FindFirstChild("Humanoid") then
Model.Humanoid.Health -= 30
end
end
end
end)
Line 4 is this line, which if your looking for the API reference for is here: RaycastParams
RayCastParams.FilterDescendantsInstances = (player.Character)
Any help would be appreciated.
Thanks in advance.
ICrann