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

Reposting this hopperbin tool issue. Any ideas on how to fix?

No one's helped and it's fallen down the list and I really need help with it ASAP.

So this happens to some of my tools, they work perfectly in studio and don't do anything in game.

I checked the output in game via developer console and got nothing.

Here's my script:

local tool = script.Parent --The hopperbin which the script is in.
local player = game.Players.LocalPlayer --The local player. (Make sure the script is a local script)
local char = player.Character --The character of the player.
local hum = char.Humanoid

tool.Selected:connect(function(mouse) --Fires the function when the event is triggered.
        mouse.Button1Down:connect(function() --Fires the function when the event is triggered.
		 if char:FindFirstChild("HumanoidRootPart") ~= nil and char.HumanoidRootPart:FindFirstChild("Fire") == nil then
			local f = Instance.new("Fire", char.HumanoidRootPart)
			f.Color = Color3.new(0.4)
			f.SecondaryColor = Color3.new(0, 0, 0)
			f.Heat = 0
			f.Size = 0
			char.Torso.Anchored = true
			while (f.Size < 9.9) do
    		f.Size = f.Size + 0.2
   			 wait(0.1)
			end
			wait(3)
			while wait(0.1) do
    		f.Size = f.Size - 0.2
			if f.Size == 2 then f:Destroy() char.Torso.Anchored = false
				end
			end 
		end
	end)
end)

Any help would be appreciated.

4 comments

0

Is this in a LocalScript? If not, make it a LocalScript...

0

It is a local script.

0

Hopperbins are broken.

0

No they aren't. I have made a different tool from a hopperbin that works.

1 answer

✓ Accepted answer

Usually when this happens to me, I usually put in some code to wait for the character and humanoid to become available.

This should guarantee that the code will run when the script is able to find the player's character and humanoid.

local tool = script.Parent --The hopperbin which the script is in.
local player = game.Players.LocalPlayer --The local player. (Make sure the script is a local script)
local char = player.Character or player.CharacterAdded:wait() --The character of the player.
repeat wait() until char
local hum = char:WaitForChild("Humanoid")

tool.Selected:connect(function(mouse) --Fires the function when the event is triggered.
        mouse.Button1Down:connect(function() --Fires the function when the event is triggered.
         if char:FindFirstChild("HumanoidRootPart") and not char.HumanoidRootPart:FindFirstChild("Fire") then --Simplified. The conditions are exactly the same, just shorter.
            local f = Instance.new("Fire", char.HumanoidRootPart)
            f.Color = Color3.new(0.4)
            f.SecondaryColor = Color3.new(0, 0, 0)
            f.Heat = 0
            f.Size = 0
            char.Torso.Anchored = true
            while (f.Size < 9.9) do
            f.Size = f.Size + 0.2
             wait(0.1)
            end
            wait(3)
            while wait(0.1) do
            f.Size = f.Size - 0.2
            if f.Size == 2 then f:Destroy() char.Torso.Anchored = false
                end
            end 
        end
    end)
end)

1 comment

0

Oh my god it works now. You are a life saver.

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