Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

why does line 15 keep erroring out? [ANSWERED] [closed]

Asked by
Prioxis 673 Moderation Voter
10 years ago

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 :

01local player = script.Parent.Parent.Parent.Parent.Parent.Name
02function onClicked(GUI)
03    if script.Parent.Spawned.Value == 1 then
04        print'pet already spawned'
05    elseif script.Parent.Spawned.Value == 0 then
06local m = Instance.new("Model", Workspace)
07m.Name = player.."'s Pet"
08local h = Instance.new("Humanoid", m)
09h.MaxHealth = 0
10local s = Instance.new("StringValue", m)
11s.Name = "Owner"
12s.Value = player
13local p = Instance.new("Part", m)
14p.Name = "Head"
15p.Position = game.Workspace:findFirstChild(player.Head).Position
View all 22 lines...

Locked by 2eggnog, OniiCh_n, TofuBytes, and Lacryma

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
4
Answered by
Lacryma 548 Moderation Voter
10 years ago

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

0
oh okay thank you Prioxis 673 — 10y
0
yay thank you it works and now my game is semi complete Prioxis 673 — 10y
Ad