Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

0

You're doing it right, you can use a remote event. Show the code for us to fix it. All of the code.

0

K, i updated it

1 answer

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)

2 comments

0

Ohh, can you please show a quick example on how to do so?

0

wrong wrong wrong wrong he is not returning anything

This discussion is preserved as it was. New answers, comments, and votes are closed.