Close, first off there are some changes that should be made:
plr = game.Players.LocalPlayer
chr = plr.Character
s = plr:GetMouse();
s.KeyDown:connect(function(key)
key = key:lower()
if key == "g" then
local f = Instance.new("Part", workspace)
f.Anchored = true
f.CanCollide = false
f.Position = chr.Head.Position + Vector3.new(2,-2,0)
spawn(function()
for i = 1, 500, 0.1 do
wait(0.1)
f.Size = f.Size + Vector3.new(1, 1, 1)
end
end)
end
end)
However, the method you are using is highly ineffecient according to the Roblox Wiki. It suggests using UserInputService or ContextActionService.
Let's take a look using ContextActionService:
context = game:GetService("ContextActionService")
function newPart()
spawn(function()
for i = 1, 500, 0.1 do
wait(0.1)
f.Size = f.Size + Vector3.new(1, 1, 1)
end
end)
end
context:BindActionToInputTypes(
actionName = "newBrick",
functionToBind = newPart,
false,
Enum.KeyCode.G
)
For more information on ContextActionService, visit
http://wiki.roblox.com/index.php?title=ContextActionService_tutorial
Above Code Is Untested
5 comments
Try doing it with a Existing Part. Because if you use the "INSTANCE.NEW" It could place it anywhere.
@TheContinentofEurope You do realize that the second parameter of "Instance.new()" marks the location of the first argument? Also, if the second parameter is not filled, then the first argument's parent is "nil".
I know that but where would the location of the part go then??
Anyways, tyler46783, what do you think this script is doing what you don't want it to do?
@TheContinentofEurope The part would go to "game.Workspace". Did you know that "workspace" is shorthand for it?