local plr = game.Players.LocalPlayer
local c = plr.Character
local torso = c:FindFirstChild("Torso")
function rockjustsu()
	local z2 = math.random(0.5,1.5)
	local z3 = math.random(0.5,1.5)
	local z4 = math.random(0.5,1.5)
	local z5 = math.random(0.5,1.5)
	local part = Instance.new("Part",game.Workspace)
	part.Name = "Rock"
	part.Anchored = true
	part.CanCollide = true
	part.BrickColor = BrickColor.new("Burnt Sienna")
	part.Size = Vector3.new(6,5,6)
	part.CFrame = torso.CFrame * CFrame.new(0,0,-3)
	part.TopSurface = "Smooth"
	part.BottomSurface = "Smooth"
	wait(0.3)
	local part2 = Instance.new("Part",game.Workspace)
	part2.Name = "Rock2"
	part2.Anchored = true
	part2.CanCollide = true
	part2.BrickColor = BrickColor.new("Burnt Sienna")
	part2.Size = Vector3.new(6,5,6)
	part2.CFrame = part.CFrame * CFrame.new(0,z2,-5)
	part2.TopSurface = "Smooth"
	part2.BottomSurface = "Smooth"
	wait(0.3)
	local part3 = Instance.new("Part",game.Workspace)
	part3.Name = "Rock3"
	part3.Anchored = true
	part3.CanCollide = true
	part3.BrickColor = BrickColor.new("Burnt Sienna")
	part3.Size = Vector3.new(6,5,6)
	part3.CFrame = part2.CFrame * CFrame.new(0,z3,-5)
	part3.TopSurface = "Smooth"
	part3.BottomSurface = "Smooth"
	local part4 = Instance.new("Part",game.Workspace)
	part4.Name = "Rock4"
	part4.Anchored = true
	part4.CanCollide = true
	part4.BrickColor = BrickColor.new("Burnt Sienna")
	part4.Size = Vector3.new(6,5,6)
	part4.CFrame = part3.CFrame * CFrame.new(0,z4,-5)
	part4.TopSurface = "Smooth"
	part4.BottomSurface = "Smooth"
	local part5 = Instance.new("Part",game.Workspace)
	part5.Name = "Rock5"
	part5.Anchored = true
	part5.CanCollide = true
	part5.BrickColor = BrickColor.new("Burnt Sienna")
	part5.Size = Vector3.new(6,5,6)
	part5.CFrame = part4.CFrame * CFrame.new(0,z5,-5)
	part5.TopSurface = "Smooth"
	part5.BottomSurface = "Smooth"
	game.Debris:AddItem(part,8)
	game.Debris:AddItem(part2,8)
	game.Debris:AddItem(part3,8)
	game.Debris:AddItem(part4,8)
	game.Debris:AddItem(part5,8)
	---Part is touched
	part.Touched:connect(function(hit)
		local c = hit.Parent
		local plr1 = c.Name
		local t = c:FindFirstChild("Torso")
		local ch = game.Players:FindFirstChild(plr1)
		if ch.Name ~= plr.Name then
				local v1 = Instance.new("BodyVelocity",t)
				v1.velocity = part.CFrame.lookVector * 90
   				v1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				wait(.2)
				v1:Destroy()
		else
			print("Not A Player")
		end
	end)
	---Part2 is touched
	part2.Touched:connect(function(hit)
		local c = hit.Parent
		local plr1 = c.Name
		local t = c:FindFirstChild("Torso")
		local ch = game.Players:FindFirstChild(plr1)
		if ch.Name ~= plr.Name then
				local v1 = Instance.new("BodyVelocity",t)
				v1.velocity = part2.CFrame.lookVector * 90
   				v1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				wait(.2)
				v1:Destroy()
		else
			print("Not A Player")
		end
	end)
	---Part3 is touched
	part3.Touched:connect(function(hit)
	local c = hit.Parent
		local plr1 = c.Name
		local t = c:FindFirstChild("Torso")
		local ch = game.Players:FindFirstChild(plr1)
		if ch.Name ~= plr.Name then
				local v1 = Instance.new("BodyVelocity",t)
				v1.velocity = part3.CFrame.lookVector * 90
   				v1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				wait(.2)
				v1:Destroy()
		else
			print("Not A Player")
		end
	end)
	--Part4 is touched
	part4.Touched:connect(function(hit)
		local c = hit.Parent
		local plr1 = c.Name
		local t = c:FindFirstChild("Torso")
		local ch = game.Players:FindFirstChild(plr1)
		if ch.Name ~= plr.Name then
				local v1 = Instance.new("BodyVelocity",t)
				v1.velocity = part4.CFrame.lookVector * 90
   				v1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				wait(.2)
				v1:Destroy()
		else
			print("Not A Player")
		end
	end)
	--Part5 is touched
	part5.Touched:connect(function(hit)
		local c = hit.Parent
		local plr1 = c.Name
		local t = c:FindFirstChild("Torso")
		local ch = game.Players:FindFirstChild(plr1)
		if ch.Name ~= plr.Name then
				local v1 = Instance.new("BodyVelocity",t)
				v1.velocity = part5.CFrame.lookVector * 90
   				v1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				wait(.2)
				v1:Destroy()
		else
			print("Not A Player")
		end
	end)
end
function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.R then
		print("R was pressed")
		rockjustsu()
		print("Jutsu should fire!")
	end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

When either I use Player1 or Player2 whichever one I pressed R with first can cast this jutsu but Player2 cant if I pressed Player1 First I don't understand why it does this because when I press R on Player1 when I first join it shoots the jutsu but when Player2 presses R if he was not first then it would print my print statements but won't make the parts but if I use Player2 first it will please help me ?

3 comments

0

Woah, could you explain it more clearly? I can see the lines where it handles the button presses, but what's going on?

0

Lines 9-140, use a loop to do the same stuff for each part.

0

I don't want to I rather have each part sepertate