Hello,
I have issue with mouse.Target . I’ve looked at devforum and devhub but found nothing similar with my issue . The issue is the mouse dosent detect anything . Here is the script:
local buses = game.Workspace.Map.Bushes:GetChildren()
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")
local bill = game.StarterGui:WaitForChild("Interract").BushesGrab
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
for i , bushes in pairs(buses) do
print("hi")
if mouse.Target.Name == "Leaf" and mouse.Target.Parent == i then
print("hey")
if bill.Adornee == nil then
print("hello")
bill.Adornee = bushes
print("aayo")
end
else
bill.Adornee = nil
print("say wahat")
end
end
The for loop will only run once so I suggest wrapping this into a mouse.Move function like so:
local buses = game.Workspace.Map.Bushes:GetChildren()
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")
local bill = game.StarterGui:WaitForChild("Interract").BushesGrab
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Move:Connect(function()
for i , bushes in pairs(buses) do
print("hi")
if mouse.Target.Name == "Leaf" and mouse.Target.Parent == i then
print("hey")
if bill.Adornee == nil then
print("hello")
bill.Adornee = bushes
print("aayo")
end
else
bill.Adornee = nil
print("say wahat")
end
end
end)
I already wattch the vid but I got error . It says
attempt to index nil with 'Parent
everything I dd is same as The Devking do but I got this error . Here is the latest script:
UIS.InputChanged:Connect(function(input)
for i , bushes in pairs(buses) do
if mouse.Target.Parent:IsA("Model") and mouse.Target.Name == bushes.Name then
bill.Adornee = mouse.Target
print("aayo")
else
bill.Adornee = nil
end
end
end)
local buses = game.Workspace.Map.Bushes:GetChildren()
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")
local bill = game.StarterGui:WaitForChild("Interract").BushesGrab
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
for i, bushes in pairs(buses) do
print("hi")
if mouse.Target ~= nil then
if mouse.Target.Name == "Leaf" and mouse.Target.Parent == i then
print("hey")
if bill.Adornee == nil then
print("hello")
bill.Adornee = bushes
print("aayo")
end
else
bill.Adornee = nil
print("say wahat")
end
end
end