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

[KEYDOWN TEST] I need help. What's wrong with the slur of code?

Asked by 9 years ago

So, I don't see any mistakes, neither does the output say anything wrong. I am totally confused.

s = game.Players.LocalPlayer:GetMouse()

s:connect(function(key) key = key:lower() if key == "g" then local f = Instance.new("Part", workspace) f.Anchored = true f.CanCollide = false f.Position = Vector3.new(0,0,0) for i = 1, 500, 0.1 do wait(0.1) f.Size = f.Vector3 +1 end end end)

0
Next time put code into a code box. Thanks! My_Comment 95 — 9y

1 answer

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
9 years ago
s = game.Players.LocalPlayer:GetMouse()

s:connect(function(key)
    key = key:lower()
    if key == "g" then
        local f = Instance.new("Part", workspace)
        f.Anchored = true
        f.CanCollide = false
        f.Position = Vector3.new(0,0,0)
        for i = 1, 500, 0.1 do
            wait(0.1)
            f.Size = f.Vector3 +1
        end
    end
end)

The first error you have in this script is you didn't include an event!

On line 3:

s:connect(function(key)

So here it is.

s.KeyDown:connect(function(key)

Also, what's the purpose of the for loop in lines 10-13?

for i = 1, 500, 0.1 do
    wait(0.1)
    f.Size = f.Vector3 +1
end

This will certainly error out, since you're not adding 1 to really anything. Vector3 will not be a member of f.

If you want your part f to expand by 1 stud on all 3 axes every tenth of a second, try this instead:

for i = 1, 500, 0.1 do
    wait(0.1)
    f.Size = f.Size + Vector3.new(1, 1, 1)
end
Ad

Answer this question