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

How could i send the player's mouse position to a serverscript?

Asked by
oSyM8V3N 429 Moderation Voter
6 years ago
Edited 6 years ago

If its possible how can i do it?

I tried doing FireServer(mouse.Hit.p), but there was an error in the serverscript when i wrote it. Any help on how to do this?

LocalScript :

UIS.InputBegan:Connect(function(Input, gameProcessedEvent)
    local KeyCode = Input.KeyCode
    if gameProcessedEvent == false then

        if KeyCode == Enum.KeyCode.F and chain == 0 and script.Parent.Combat.active.Value == false then
            chain = 1
            print("1 fired")
        local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(LeftKBlast)
animTrack:Play()
workspace.CurrentCamera.Sounds.P2:Play()
Event:FireServer(mouse.Hit.p)

ServerScript :

Event.OnServerEvent:Connect(function(player, mouse.Hit.p)
local x = Instance.new("Part")
x.BrickColor = BrickColor.new("Institutional white")
x.Shape = "Ball"
x.Material = "Neon"
x.Size = Vector3.new(1.7,1.7,1.7)
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.CanCollide = false
x.Transparency = 0
x.Name = "Blast"
local xx = Instance.new("Part")
xx.BrickColor = BrickColor.new("Toothpaste")
xx.Shape = "Ball"
xx.Material = "Neon"
xx.Size = Vector3.new(2,2,2)
xx.TopSurface = "Smooth"
xx.BottomSurface = "Smooth"
xx.CanCollide = false
xx.Transparency = .1
xx.Name = "Blast2"
x.CFrame = game.Players.LocalPlayer.Character:FindFirstChild("RightHand").CFrame*CFrame.new(0,0,0)
xx.CFrame = game.Players.LocalPlayer.Character:FindFirstChild("RightHand").CFrame*CFrame.new(0,0,0)
local pos1 = mouse.Hit.p 
local direction1 = (pos1 - x.Position).unit  
y = Instance.new("BodyVelocity")
y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
y.Velocity = direction1 * 200
x.Parent = game.Workspace
xx.Parent = game.Workspace
y.Parent = x
local pos = mouse.Hit.p 
local direction = (pos - xx.Position).unit  
local yy = Instance.new("BodyVelocity")
yy.maxForce = Vector3.new(math.huge, math.huge, math.huge)
yy.Velocity = direction * 200
yy.Parent = xx

end)
0
You're doing it right, you can use a remote event. Show the code for us to fix it. All of the code. CootKitty 311 — 6y
0
K, i updated it oSyM8V3N 429 — 6y

1 answer

Log in to vote
-2
Answered by 6 years ago

You need a RemoteFunction A RemoteFunction allows you to return stuff to whatever script called the RemoteFunction A RemoteEvent is the same but you can't return stuff.

RemoteFunction:InvokeServer(Mouse.Hit.p)
0
Ohh, can you please show a quick example on how to do so? oSyM8V3N 429 — 6y
0
wrong wrong wrong wrong he is not returning anything hiimgoodpack 2009 — 6y
Ad

Answer this question