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 10 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 — 10y

1 answer

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
10 years ago
01s = game.Players.LocalPlayer:GetMouse()
02 
03s:connect(function(key)
04    key = key:lower()
05    if key == "g" then
06        local f = Instance.new("Part", workspace)
07        f.Anchored = true
08        f.CanCollide = false
09        f.Position = Vector3.new(0,0,0)
10        for i = 1, 500, 0.1 do
11            wait(0.1)
12            f.Size = f.Vector3 +1
13        end
14    end
15end)

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

On line 3:

1s:connect(function(key)

So here it is.

1s.KeyDown:connect(function(key)

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

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

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:

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

Answer this question