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
9 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 :

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)

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
9 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 — 9y
0
yay thank you it works and now my game is semi complete Prioxis 673 — 9y
Ad