Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I do this while function?

I want to make a script so that when the tool is activated I can do a repeating function.

I was thinking

while game.StarterPack.Tool.Activated do p = game.Players.LocalPlayer m = p:GetMouse() b = Instance.new("Part") b.Size = Vector3.new(0,0,0) b.Position = m.Target.Position b.Anchored = true end)

but it doesn't seem right. Please help!

1 comment

0

New Problem. Brick won't show up. Code: Player = game.Players.LocalPlayer Mouse = Player:GetMouse() while script.Parent.Parent.Activated == true do b = Instance.new("Part", game.Workspace) b.BrickColor = BrickColor.new("Really black") b.CFrame = Mouse.Target.CFrame b.Anchored = true b.Material = "Concrete" end

1 answer

1

Is the script a LocalScript? Only LocalScripts can access LocalPlayer.

2

while game.StarterPack.Tool.Activated == true do -- better than what you did before

3

You have to set the part's size to something bigger than 0,0,0.

4

Use CFrame instead on the position. Two parts can't be made to overlap with Position, you need to use CFrame instead for that.

b.CFrame = m.Target.CFrame

This discussion is preserved as it was. New answers, comments, and votes are closed.