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

why does line 15 keep erroring out? [ANSWERED]

I'm making a remake of grow a brick but on line 15 keeps having an error and when I go to clone my follow script from the workspace into the model it doesn't do it

and this is the error

18:42:44.946 - Argument 1 missing or nil 18:42:44.947 - Script 'Players.Player1.PlayerGui.BrickParent.BKG.Spawn.Click', Line 15 18:42:44.947 - Stack End 18:42:44.949 - Disconnected event because of exception

heres my script :

local player = script.Parent.Parent.Parent.Parent.Parent.Name
function onClicked(GUI)
	if script.Parent.Spawned.Value == 1 then 
		print'pet already spawned'
	elseif script.Parent.Spawned.Value == 0 then
local m = Instance.new("Model", Workspace)
m.Name = player.."'s Pet"
local h = Instance.new("Humanoid", m)
h.MaxHealth = 0
local s = Instance.new("StringValue", m)
s.Name = "Owner"
s.Value = player
local p = Instance.new("Part", m)
p.Name = "Head"
p.Position = game.Workspace:findFirstChild(player.Head).Position
script.Parent.Spawned.Value = 1
local f = game.Workspace.Follow:clone()
f.Parent = m
f.Disabled = false
	end
	end
script.Parent.MouseButton1Click:connect(onClicked)

1 answer

✓ Accepted answer

p.Position = game.Workspace:findFirstChild(player.Head).Position

FindFirstChild does not work like that, it will only accept a string as it's argument.

Change that line to:

p.Position = game.Workspace:findFirstChild(player).Head.Position

2 comments

0

oh okay thank you

0

yay thank you it works and now my game is semi complete

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