Hi there!
I'm need to always get mouse position when player pressing X.
How i can do that with RemoteEvent?
Here my code:
[CODE lang="lua" title="LocalScript"]-- Events
local PlacePCE = game.ReplicatedStorage.PlacePC_Event
local PlaceCE = game.ReplicatedStorage.PlaceC_Event
-- Services
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if UIS:GetFocusedTextBox() then
return
end
if input.KeyCode == Enum.KeyCode.X then
local MouseTF = game.Players.LocalPlayer:GetMouse().TargetFilter
local MouseHP = game.Players.LocalPlayer:GetMouse().Hit.Position
PlacePCE:FireServer(MouseTF, MouseHP)
end
end)[/CODE]
[CODE lang="lua" title="Script"]local isPlacingPC = false
local function PlacingPC(player, MouseTF, MouseHP, input)
local PreviewCube = game.ReplicatedStorage.Cube:Clone()
PreviewCube.Parent = game.Workspace["Build_".. player.Name]
PreviewCube.Name = "PreviewCube"
MouseTF = PreviewCube
isPlacingPC = true
while isPlacingPC == true do
PreviewCube.Position = MouseHP
wait(0.05)
end
end
game.ReplicatedStorage.PlacePC_Event.OnServerEvent:Connect(PlacingPC)[/CODE]
I'm need to always get mouse position when player pressing X.
How i can do that with RemoteEvent?
Here my code:
[CODE lang="lua" title="LocalScript"]-- Events
local PlacePCE = game.ReplicatedStorage.PlacePC_Event
local PlaceCE = game.ReplicatedStorage.PlaceC_Event
-- Services
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if UIS:GetFocusedTextBox() then
return
end
if input.KeyCode == Enum.KeyCode.X then
local MouseTF = game.Players.LocalPlayer:GetMouse().TargetFilter
local MouseHP = game.Players.LocalPlayer:GetMouse().Hit.Position
PlacePCE:FireServer(MouseTF, MouseHP)
end
end)[/CODE]
[CODE lang="lua" title="Script"]local isPlacingPC = false
local function PlacingPC(player, MouseTF, MouseHP, input)
local PreviewCube = game.ReplicatedStorage.Cube:Clone()
PreviewCube.Parent = game.Workspace["Build_".. player.Name]
PreviewCube.Name = "PreviewCube"
MouseTF = PreviewCube
isPlacingPC = true
while isPlacingPC == true do
PreviewCube.Position = MouseHP
wait(0.05)
end
end
game.ReplicatedStorage.PlacePC_Event.OnServerEvent:Connect(PlacingPC)[/CODE]