Code:
_G.PutToolOn = function(plr,tooltoquip,class) if tostring(tooltoquip) == "Hatchet" then local arm = game.Workspace.tostring(plr)['Right Arm'] local iten = game.Lighting:findFirstChild(tostring(class).."Hatchet"):clone() iten.Parent = game.Workspace local w1 = Instance.new("Weld",arm) w1.Part0 = arm w1.Part1 = iten.Handle w1.C0 = CFrame.new(0,-1,-.8) * CFrame.fromEulerAnglesXYZ(80,0,0) end end
Output:
21:16:27.792 - _G.PutToolOn(Player1,Hatchet,Bronze):1: attempt to call field 'PutToolOn' (a nil value)
Called it in command bar with:
_G.PutToolOn(Player,Hatchet,Bronze)
The function is in a normal script in ServerScriptService
function _G.PutToolOn(plr,tooltoquip,class) --All I did was remove the = and moved the _G. tag. if tostring(tooltoquip) == "Hatchet" then local arm = game.Workspace.tostring(plr)['Right Arm'] local iten = game.Lighting:findFirstChild(tostring(class).."Hatchet"):clone() iten.Parent = game.Workspace local w1 = Instance.new("Weld",arm) w1.Part0 = arm w1.Part1 = iten.Handle w1.C0 = CFrame.new(0,-1,-.8) * CFrame.fromEulerAnglesXYZ(80,0,0) end end
There was an error on line three. Also if this is just a utility function why not use a ModuleScript?
_G.PutToolOn = function(plr,tooltoquip,class) if tostring(tooltoquip) == "Hatchet" then local arm = game.Workspace[tostring(plr)]['Right Arm'] local iten = game.Lighting:findFirstChild(tostring(class).."Hatchet"):clone() iten.Parent = game.Workspace local w1 = Instance.new("Weld",arm) w1.Part0 = arm w1.Part1 = iten.Handle w1.C0 = CFrame.new(0,-1,-.8) * CFrame.fromEulerAnglesXYZ(80,0,0)