#Gun my friend is trying to make a gun, i dont even know myselfBut i'm willing to help

1 messages · Page 1 of 1 (latest)

small kayak
#
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local remoteEvent = game.ReplicatedStorage:WaitForChild("ShootEvent")

tool.Activated:Connect(function()
    local targetPosition = mouse.Hit.Position
    remoteEvent:FireServer(targetPosition)
end) ```
keen junco
#

What do you need from us?

#

@small kayak

small kayak
#

I need a team who is willing to only get paid if the game becomes successful as well as hope learning how to script a gun

small kayak
keen junco
#

That is simply not how this world works

small kayak
#

That's what I thought

#

😅

keen junco
#

No harm in hoping peepocry

small kayak
#

Im trying to find the best way to fix this

keen junco
#

What is it you need fixed?

small kayak
#

I have basic code AI ofc but i don't know if it will work

#

I try making a game myself back in the day.But I lost everything from my family and my main account region got switched over to VNG

#

So I don't have access to studios. No more like I used to used to

keen junco
small kayak
#

-- This function runs every time something touches the part
local function onTouch(otherPart)
    -- Look for a "Humanoid" inside whatever touched the part
    local character = otherPart.Parent
    local humanoid = character:FindFirstChild("Humanoid")

    -- If a Humanoid was found, set its health to 0
    if humanoid then
        humanoid.Health = 0
    end
end

-- Connect the function to the 'Touched' event
trapPart.Touched:Connect(onTouch) ```
#

local remoteEvent = game.ReplicatedStorage:WaitForChild("ShootEvent")

remoteEvent.OnServerEvent:Connect(function(player, targetPosition)
local character = player.Character
local gun = character:FindFirstChildOfClass("Tool")
if not gun then return end

local startPosition = gun.Handle.Position
local direction = (targetPosition - startPosition).Unit

-- Raycasting to find hit target
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude

local raycastResult = workspace:Raycast(startPosition, direction * 300, raycastParams)

if raycastResult then
    local hitPart = raycastResult.Instance
    local model = hitPart:FindFirstAncestorOfClass("Model")
    if model then
        local humanoid = model:FindFirstChild("Humanoid")
        if humanoid then
            humanoid:TakeDamage(10) -- Damage amount
        end
    end
end

end)

#

This is all

#

I would assume I would need to first make a server script before moving on to weapons

keen junco
#

What's not working?

small kayak
#

That's the problem I have no way to test it

#

And hes gone as of this moment right now

keen junco
#

The code looks fine to me

#

Basic server-authoritative hitscan

small kayak
#

Ok thank you so much

#

I kinda get paranoid some times

#

But if you wouldn't mind, do you know anywhere?I could learn how to script?

small kayak
#

Oh

keen junco
#

Your local library, this very server, YouTube, the DevForum, Amazon.ca, etc

small kayak
#

Bet

#

If I could close this myself, I would and I have no way to say thank you the most

vestal cave
#

🤔