I am using a script in starter pack.
While im typing, it says I can use LocalPlayer and :GetMouse()
Help? Code:
game.Players.PlayerAdded:Connect(function(plr)
local mouse = plr:GetMouse()
local mouseDistance = 30
local distance = nil
local Mouse1Down = false
local Mouse2Down = false
local function GetMaxDistance()
distance = (player.Character.HumanoidRootPart.Position - mouse.Target.Position).Magnitude
-- print(distance)
end
function DestroyBlock()
GetMaxDistance()
if mouse.Target.Name == "log" and distance <= mouseDistance then
local logStregth = 5
local setBlock = mouse.Target
for i = 0,logStregth,1 do
if Mouse2Down == false then
print("Mouse went up")
break
end
if i == logStregth then
setBlock:Destroy()
if player.Items:FindFirstChild("Log") then
player.Items.Log.Value += 1
else
local newLogItem = Instance.new("NumberValue", player.Items)
newLogItem.Name = "Log"
newLogItem.Value = 1
end
end
wait(1)
end
end
end
function PlaceBlock()
GetMaxDistance()
if distance <= mouseDistance then
local newBlock = game.ReplicatedStorage.Assets.grass:Clone()
newBlock.CFrame = CFrame.new(mouse.Target.Position + Vector3.new(0,4,0))
newBlock.Parent = mouse.Target.Parent
end
end
mouse.Button1Down:Connect(PlaceBlock)
mouse.Button2Down:Connect(DestroyBlock)
mouse.Button1Down:Connect(function()
Mouse1Down = true
end)
mouse.Button2Down:Connect(function()
Mouse2Down = true
end)
mouse.Button1Up:Connect(function()
Mouse1Down = false
end)
mouse.Button2Up:Connect(function()
Mouse2Down = false
end)
yes, these 2 lines of code aint working IT IS A SCRIPT, NOT A LOCAL OR MOUDLE

1 comment
:GetMouse() only works in LocalScript