Ad
Log in to vote
0

Making a script that makes rocks fall on a player?

Asked by 9 months ago

So, when I put this code in, the output box just says "argument 1 missing or nil" at line 15 and I'm quite positive that there could possible be more errors. I personally Don't get what it's coming from, but here's my script. It makes 20 rocks spawn over the head of all players.

rock = script.Parent.Parent.Parent.rocky.Rock
for i, v in pairs(game.Players:GetChildren()) do
    getp = Instance.new("StringValue")
    getp.Value = tostring(v.Name)
    getp.Parent = game.Workspace
end


for i = 1,20 do
    local p = rock:Clone()
    p.Parent = script.Parent.Parent.Parent
    for i, v in pairs(game.Workspace:GetChildren()) do
        if v:IsA("StringValue") then
            local gname = v.Value
            local pl = game.Workspace:FindFirstChild(gname.Value)
            p.Position = pl.Position + Vector3.new(0,40,0)
            p.Anchored = false
        end
    end
end

1 answer

Log in to vote
1
Answered by
Denny9876 1136 Moderation Voter
9 months ago

I think you typed something incorrectly. On line 14 “gname” is v.Value, but on line 15 you are trying to find the value of the value of v? Basically the script is thinking it’s trying to find v.Value.Value.

Simply just change “v.Value” on line 14 into “v”.

0
thank winner208 74 — 9mo
Ad

Answer this question