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

my parts keep spawning in the same place idk why how do i fix?

here it is my script i am trying to make my own but the parts keep spawning in the same place

i am trying to make it like spike are coming out of the player with the spike staying in the same place but they stay in the same place they spectate

game.ReplicatedStorage.overse.OnServerEvent:Connect(function(player)
	local folder = workspace:FindFirstChild("DebrisFolder") or Instance.new("Folder",workspace)
	folder.Name = "DebrisFolder"
	local char = player.Character
	local root = player.Character.HumanoidRootPart
	local position = Instance.new("BodyVelocity",root)
	position.MaxForce = Vector3.new(99999999999999999,999999999999999999999,9999999999999999999)
	position.P = 300
	position.Velocity = root.CFrame.LookVector *1
	game.Debris:AddItem(position,3)
	local  function spl()
	local pike = game.Lighting.overseare:Clone()
	sideval = .5
	local side = math.random(-sideval,sideval)
	sizex  = .76
	local extra = math.random(-1.1,1.1)
	sizey = pike.Size.Y/4
	 pike.Parent = workspace
	pike.CFrame = root.CFrame * CFrame.new(side,sizey,4 + extra)
	
	
	
	
	end	
	for i = 1,50 do
		spl()
	end
end)

the other guys script

game.ReplicatedStorage.Ice.OnServerEvent:Connect(function(player)
	local folder = workspace:FindFirstChild("DebrisFolder") or Instance.new("Folder",workspace)
	folder.Name = "DebrisFolder"
	local char = player.Character
	local root = player.Character.HumanoidRootPart
	local position = Instance.new("BodyVelocity",root)
	position.MaxForce = Vector3.new(99999999999999999,999999999999999999999,9999999999999999999)
	position.P = 300
	position.Velocity = root.CFrame.LookVector *1
	game.Debris:AddItem(position,3)
	
	
	val =  -3
	sizez = 3
	sezex = 10
	sideval = .5
	local  function ice()
	local extra = math.random(-1.1,1.1)
	local shard = game.Workspace.Union:Clone()
	local side = math.random(-sideval,sideval)
	up = shard.Size.Y/4
	local rotate = math.random(0,180)
	local mro = math.random(99,100)
	if mro == 99 then
		sro = math.random(8/1)/10
		uro = mro + sro
	else
		
		sro = math.random(1,3)/10
		uro = mro + sro
				
	end
	local lean = math.random(4,4)/10
	shard.Size = Vector3.new(sizez,sezex,sizez)
	shard.Parent = folder
	shard.CFrame = root.CFrame * CFrame.new(side,-up,val + extra)
	shard.CFrame =  shard.CFrame * CFrame.fromEulerAnglesXYZ(uro,rotate,0.4)
	
	val = val -2
	
	sideval = sideval +.5
	
	game.Debris:AddItem(shard,3)
	
	
	end
	for i = 1,50 do
		ice()
		wait()
	end
	
end)

4 comments

0

Maybe because you put 99999999999999999 in each vector.

0

nope that just stops the player from moving what i am trying to do it make parts come out the player in a line but 1 studs like part 1 stud and part again

0

just use math.huge

0

thats not the prob

1 answer

GENERAL PRACTICE

Use math.huge() instead of 99999999999999999

Use :WaitForChild() before changing a part (such as getting the HumanoidRootPart)

Use :GetService() for Debris, ReplicatedStorage, and Lighting

Use ServerStorage rather than Lighting to hold your cloned items

Check that the "folder" is an actual instance instead of using "or"

ISSUES

Use a wait(#) inside the for-loop so that the loop doesn't run all at once (i.e., has a wait time of zero)

Use local variables for sizex, sizey, and sideval

Make sure that you're clonable part has Anchored set to false

REVISED SERVER SCRIPT

game:GetService("ReplicatedStorage"):WaitForChild("overse").OnServerEvent:Connect(function(player)
	local folder = workspace:FindFirstChild("DebrisFolder")
	if not folder then
		folder = Instance.new("Folder")
		folder.Parent = workspace
		folder.Name = "DebrisFolder"
	end
	
	local char = player.Character
	local root = char:WaitForChild("HumanoidRootPart")
	
	local position = Instance.new("BodyVelocity")
	position.Parent = root
	position.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	position.P = 300
	position.Velocity = root.CFrame.LookVector * 1

	game:GetService("Debris"):AddItem(position, 3)

	for i = 1, 50, 1 do
		local pike = game:GetService("ServerStorage"):WaitForChild("overseare"):Clone()
		local sideval = .5
		local sizex  = .76
		local sizey = (pike.Size.Y / 4)
		local side = math.random(-sideval, sideval)
		local extra = math.random(-1.1, 1.1)
		pike.Parent = workspace
		pike.CFrame = root.CFrame * CFrame.new(side, sizey, (4 + extra))
		wait()
	end
end)

I'm not quite sure how the spikes are supposed to move, but this should allow you to see multiples of them moving.

1 comment

0

lookVector is deprecated in favour of LookVector and the parent argument Instance.new(class, parent) is deprecated and it's not a good idea to parent first always parent last

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