#Raycasting not working all the time

19 messages · Page 1 of 1 (latest)

keen ice
#

So ur raycast ?

#

isnt working

#

i might be able to help onthat

#

@astral yoke

astral yoke
#

alright

keen ice
#

can i test the game to figure out whats going on

astral yoke
#

wym

keen ice
#

So i can see why it isnt working

astral yoke
#

I can publish the game and send the link

keen ice
#

k

astral yoke
#

alr 1 sec

keen ice
#

kk

astral yoke
keen ice
#

yea its hittign a humaniod

astral yoke
keen ice
#

k

upbeat topazBOT
#

studio** You are now Level 1! **studio

astral yoke
#

I cant upload a video, but when I shoot someone it dont always do damage, even if you are looking directly at them, any ideas on how to fix? here is code :gunscript (local): ```lua
local players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")

local player = players.LocalPlayer
local mouse = player:GetMouse()

local gun = script.Parent
local shot = rs:FindFirstChild("shot")
local dmg = gun:GetAttribute("damage")

mouse.Button1Down:Connect(function()
shot:FireServer(gun, gun.start.Position, mouse.Hit.Position)
end)

dmg script (global)
```lua
local rs = game:GetService("ReplicatedStorage")
local shot = rs:FindFirstChild("shot")

shot.OnServerEvent:Connect(function(plr, gun, start, stop)
    local dir = stop - start
    local raycast = workspace:Raycast(start, dir)
    local dmg = gun:GetAttribute("damage")
    if raycast then
        local hit = raycast.Instance.Parent
        local human = hit:FindFirstChild("Humanoid")
        
        if human and hit.Name ~= plr.Name then
            human.Health -= dmg
            if human.Health == 0 then
                plr.leaderstats.kills.Value += 1
                human.Health = 100
            end
        end
    end
end)
#

when "shooting" it will give nil in return even if its hitting a player