[HELP] Problem with localplayer

Hello, today I was doing a script for when you click a button the handle of the tool ( inside the tools is the gui that can change handle of tool’s BrickColor )

Ok so my issue is that when I try to get the workspace local player name I can’t,
Here is a photo of my script.

It gives me this error

If someone can help me please reply this post

I only added blue button for testing how it works

The error means that there is nothing in workspace named “plrname”. When you put workspace.plrname, that’s what it looks for.

I know but I dont know how to get LocalPlayer name for get the Handle’s tool

I know that using my own name or even doing prints works, but I didn’t find anything about getting the name of the LocalPlayer…
Can someone help me ?

local plr = game.Players.LocalPlayer
local plrName = plr.Name

local bazul = script.Parent.Frame.azul
local brojo = script.Parent.Frame.rojo
local bverde = script.Parent.Frame.verde
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

bazul.MouseButton1Click:Connect(function()
	local Tool = character:FindFirstChild("Tool") or player.Backpack:FindFirstChild("Tool")
	if Tool then
		local Handle = Tool:FindFirstChild("Handle")
		if Handle then
			Handle.BrickColor = BrickColor.new(23)
		end
	end
end)

HolisThaDev,

The issue is that the code thinks you are directly referring to a child within the workspace itself.
When using variables to call children, use this:

local name = something something

game.Workspace[name]

If confused, let me know and ill write a clearer explanation.

1 Like


Doesn’t works

I do not understood what u wanna mean

It is alright, ill send you my iteration of the code. Hang tight!

This should work. The error seems to be occurring because you’re trying to index the frame within the frame but it doesn’t exist.

local bazul = script.Parent.azul
local brojo = script.Parent.rojo
local bverde = script.Parent.verde
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

bazul.MouseButton1Click:Connect(function()
	local Tool = character:FindFirstChild("Tool") or player.Backpack:FindFirstChild("Tool")
	if Tool then
		local Handle = Tool:FindFirstChild("Handle")
		if Handle then
			Handle.BrickColor = BrickColor.new(23)
		end
	end
end)

local bazul = script.Parent.Frame.azul

local brojo = script.Parent.Frame.rojo

local bverde = script.Parent.Frame.azul

local plr = game.Players.LocalPlayer.Name

local plrname = plr

bazul.MouseButton1Click:Connect(function()

game.Workspace[plugin].Tool.Handle.BrickColor = BrickColor.new(23)

end)

i edit it a little bit but works, thanks !

1 Like

thanks for the help you too ! :fire: :fire: :fire:


there it is the final thing !