Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why my ball fall off the map and not shooting in the mouse direction?

Asked by 4 years ago

So i tried to make a ball shoot in mouse direction with a remote event. I'm new with remote events so is my first try.

I get this error : ServerScriptService.Script:12: attempt to index local 'mouse' (a nil value)

There is located the remote event : game.ReplicatedStorage.RemoteArunca

There is located the server script : game.ServerScriptService.Script Server script content:

local remote = game.ReplicatedStorage.RemoteArunca

remote.OnServerEvent:Connect(function(player, mouse)
    local x = Instance.new("Part")
    x.Size = Vector3.new(10,10,10)
    x.Material = "Neon"
    x.Parent = workspace
    x.CanCollide = false
    x.Shape = "Ball"
    local y = Instance.new("BodyVelocity")
    y.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    y.Velocity = (x.Position - mouse.Hit.p).unit * -100
end)

There is located the local script : game.StarterPack.LocalScript Local script content:

local remote = game.ReplicatedStorage.RemoteArunca

game:GetService("UserInputService").InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.F then
        remote:FireServer()
    end
end)

I want the ball to shoot in mouse direction. The ball is just spawning in my character torso and fall off the map

Answer this question