I already got that covered, but looking at Player, I'm trying to make some magic work out. But, how do I fix or do this properly. Everything is fine for now.


script.Parent.FireQ.OnServerEvent:Connect(function(player,q,k) --Q
	
	
	local Character = player.Character
	local Velo = Instance.new("BodyPosition",Character.HumanoidRootPart)
	Velo.Position = Character.UpperTorso.Position
    Velo.P = 30000

	local cam = game.Workspace.CurrentCamera
    local equipped = false
    local player = game.Players.LocalPlayer
    local Root = Character:WaitForChild("HumanoidRootPart")
	local Humanoid = Character:WaitForChild("Humanoid")
    if not Character or not Character.Parent then
    Character = player.CharacterAdded:wait()
	local Root = Character:WaitForChild("HumanoidRootPart")
	local Humanoid = Character:WaitForChild("Humanoid")
end
	local Mouse = player:GetMouse()
    local prev_mousehit

if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
		hum.AutoRotate = false
		if Mouse.Hit.p ~= prev_mousehit then
			tor.CFrame = CFrame.new(tor.Position, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
			prev_mousehit = Mouse.Hit.p
		end
	else
		hum.AutoRotate = true
	end


7 comments

0

better explain your question it makes no sense.

0

why do we have multiple of the same references to root, humanoid, and player in the same scope?

0

we arent even using half of the variables.

0

You really don't want to mess with a player's mouse, or probably a player's camera, in server code. If you do get it to work, it will likely be too slow. Instead, figure out what info the client should send through a RemoteEvent to do just the things everyone should see.

0

^ Any client side objects should be handled client side. No exceptions. Also, the LocalPlayer property of the Players service is only accessible client side. If you had done some basic research, you would have discovered the impossibility of this script working. A large amount of questions have already been asked on this topic.

0

I recommend doing all of this client sided, sending a remote event when the player hits someone with the magic, having the server check with raycasting whether or not the hit was feasible, and then causing any server wide effects on the server.

0

Dealing damage, creating effects, etc.