Hello, I am FrezeTagger, I am trying to make an gun for a game. I want when player's Mouse's position is changed, Part's Rotate will be like Mouse's position.Here is the codes:
LocalScript:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("GunCam")
local MouseEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("MouseEvent")
Event.OnClientEvent:Connect(function(Thing)
local Player = game:GetService("Players").LocalPlayer
local mouse = Player:GetMouse()
local Gun = workspace:WaitForChild("Gun")
local PlayerName = Gun:WaitForChild("PlayerName").Value
while PlayerName == Player.Name do
wait(0.0000001)
workspace.CurrentCamera.CameraType = "Scriptable"
workspace.CurrentCamera.CFrame = Gun.HareketEtcek.CameraPart.CFrame
MouseEvent:FireServer(mouse.Hit.X, mouse.Y)
end
end)
Global Script:
local MouseEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("MouseEvent")
local Gun = workspace:WaitForChild("Gun")
local PlayerName = Gun:WaitForChild("PlayerName")
local HareketEtcek = Gun:WaitForChild("HareketEtcek")
MouseEvent.OnServerEvent:Connect(function(player,MouseHitX,MouseY)
if player.Name == PlayerName.Value then
HareketEtcek.Orientation = Vector3.new(MouseHitX, MouseY)
end
end)

1 comment
Orientation requires a 3rd peramiter i belive. you have x and y but you also need z.