Alright, so in this script once you click the left mouse button the script is to clone the Handle(Brick) inside the LocalScript(The local script is inside a Hopperbin tool). However, I am trying to spawn the brick to follow your mouse. I attempted to do the Body Gyro and Positioning, however I keep getting the output message bad cast. Not only that the brick doesn't respond to the mouse leaving me clueless on what I did wrong. Help would be greatly appreciated, thank you.

bin = script.Parent 
player = script.Parent.Parent.Parent
me = script.Parent.Parent.Parent
local LocalPlayer = game.Players.LocalPlayer
Mouse = LocalPlayer:GetMouse()

function onButton1Down(mouse)
if not enabled then
		return
	end

	local player = game.Players.LocalPlayer
	if player == nil then return end

enabled = false
	
enabled = false
mouse.target = Mouse
		for i = 1, 1 do	
local	x2 = script.Handle:clone()
		x2.Name = "Fire" 
		x2.CanCollide = false
		x2.Anchored = false
		x2.Transparency = 0
		x2.Parent = game.Workspace
		game.Debris:AddItem(x2, 4)
		x2.CFrame = game.Players.LocalPlayer.Character.Head.CFrame*CFrame.new(0,0,0)

local	BodyGyro = Instance.new("BodyGyro")
		BodyGyro.Parent = x2
		BodyGyro.D = 5000
		BodyGyro.MaxTorque = Vector3.new(90,90,90)
		BodyGyro.P = 300
		
		
local	BodyPos = Instance.new("BodyPosition")
		BodyPos.Parent = x2
		BodyPos.D = 1250
		BodyPos.maxForce = Vector3.new (2000,2000,2000)
		BodyPos.P = 1000
		BodyPos.Position = Vector3.new (mouse.hit.p)
		
			end
		
		while true do
		
		mouse.target = Mouse
		

			wait(.1)
			end		
	
	
	
	
	
	
	
	
	
	
		
		
wait()
           
	wait(5)
enabled = true
	end
	

enabled = true
function onS(mouse) 
mouse.Button1Down:connect(function() onButton1Down(mouse) end) 
end 
bin.Selected:connect(onS)

2 comments

0

Is this in a local script? And if so, where is the script located?

0

The script is located within the HopperBin Tool