Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why does this not work? (Mouse problem, specifically target)

Local script inside player gui.

local player = game.Players.LocalPlayer
playerMouse = player:GetMouse()
while true do
	wait()
	if playerMouse.Target ~= nil then
	
		
		if playerMouse.Target == "BoxOne" then
			print("BoxOne is awesome")
		end
		
	end
	wait()
end

3 comments

0

if playerMouse then dont use if playerMouse.Target ~= nil

0

My guess is that you forgot to actually look for the name property of the target. Try using ' if playerMouse.Target.Name == "BoxOne" then ' instead.

0

Use local playermouse on the top after local player

1 answer

You can use pcall to detect if you are able to get a UserId from the name, as it will error if there is no user with the given name:

local NameTaken = pcall(function()
    return game.Players:GetUserIdFromNameAsync("Name here")
end)
if not NameTaken then
    print("name free")
end

This discussion is preserved as it was. New answers, comments, and votes are closed.