Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Xoqex 75
10 years ago

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.

0
Is this in a LocalScript? If not, make it a LocalScript... Muoshuu 580 — 10y
0
It is a local script. Xoqex 75 — 10y
0
Hopperbins are broken. ChipioIndustries 454 — 10y
0
No they aren't. I have made a different tool from a hopperbin that works. Xoqex 75 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

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)

0
Oh my god it works now. You are a life saver. Xoqex 75 — 10y
Ad

Answer this question