here is the script :
seed=script.Parent
seed.Activated:Connect(function() local i=Instance.new("Part",game.Workspace) i.BrickColor=Random i.Position = game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(0,0,-5) seed:Destroy() end)
here is the script :
seed=script.Parent
seed.Activated:Connect(function() local i=Instance.new("Part",game.Workspace) i.BrickColor=Random i.Position = game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(0,0,-5) seed:Destroy() end)
This should work, I think,
local seed=script.Parent
local offset = Vector3.new(0,0,-5)
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
seed.Activated:Connect(function()
local i = Instance.new("Part")
i.Parent = game.Workspace
i.BrickColor = BrickColor.Random()
i.Position = Character.HumanoidRootPart.Position + (Character.HumanoidRootPart.CFrame.lookVector * offset)
seed:Destroy()
end)
The reason that I don't set the parent of the new instance on line 7 is because it has been documented to cause performance issues. You can read about it here. Secondly you can't set the brick color as random. You have to use BrickColor.[Color] or set the brick color with a string.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Because its in a local script it won't work so move it to a script and then find a diffrent way to get the torso of the player since localPlayer doesn't work in scripts
have spaces between the equal signs front and back or it will not work
You should use either lookvector or rightvector.