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

Yes I know... Works in studio, doesn't work in-game?

Asked by
Cuvette 246 Moderation Voter
8 years ago

Basically I have a script to cut down a tree. Works fine and everything in studio, but when it comes to playing normally it just doesn't do a thing or even say anything in the dev console. Here is the script, if you have any idea that would be great.

local tool = script.Parent
local player = tool.Parent.Parent
debounce = true
player:WaitForDataReady()

function Collect(mouse)
    if mouse.Target ~= nil then
    if mouse.Target.Parent.Name == "Tree1" then
local thetree = mouse.Target.Parent
    if (mouse.Target.Position - player.Character.Torso.Position).magnitude <= 20 then
    if thetree.Hide.Value == 0 then
    if debounce == true then

local origwalkspeed = player.Character.Humanoid.WalkSpeed   


    debounce = false

    player.Character.Humanoid.WalkSpeed = 0

    local bg = Instance.new("BillboardGui")
    bg.Parent = player.PlayerGui
    bg.Adornee = player.Character.Head
    bg.Size = UDim2.new(4, 0, 4, 0)
    bg.StudsOffset = Vector3.new(0, 5, 0)
    local il = Instance.new("ImageLabel")
    il.Parent = bg
    il.Image = "http://www.roblox.com/asset/?id=420600020"
    il.Size = UDim2.new(1, 0, 1, 0)
    il.BackgroundTransparency = 1



    wait(thetree.Time.Value)

    bg:remove()

    player.Character.Humanoid.WalkSpeed =  origwalkspeed

    player.leaderstats.Wood.Value =     player.leaderstats.Wood.Value + thetree.GiveAmount.Value

    debounce = true
    thetree.Hide.Value = 1

    end
    end
    end
    end
    end
end


script.Parent.Selected:connect(function(mouse)
mouse.Button1Down:connect(function() Collect(mouse) end)
end)
0
Do you get any errors? NRCme 0 — 8y
0
I get nothing at all from it Cuvette 246 — 8y
0
Well I have no idea.. NRCme 0 — 8y
0
If it helps, this script is for an axe tool. The tree's are other models in workspace which have their own values inside each of them such as respawn time, cutting time and value. Cuvette 246 — 8y
View all comments (6 more)
0
Put some prints in the script to test it. When you run the game, check to see what things got printed and which ones didn't. TheDeadlyPanther 2460 — 8y
0
It doesn't print anything past the first function or even the first function infact Cuvette 246 — 8y
0
maybe it's the WaitForDataReady()?? NRCme 0 — 8y
0
I've tried removing it and assigning it to other things, not happening :/ Cuvette 246 — 8y
0
Try completely getting rid of line 54 and replacing it with, mouse.Button1Down:connect(Collect). The way you did it seems like it might be causing a problem. User#11440 120 — 8y
0
I worked out I was using a HopperBin! Such an idiot. So yeah I changed it to a Tool used a Localscript and modified the script a bit to work with a Tool. But got it working! Thanks guys (: Cuvette 246 — 8y

1 answer

Log in to vote
0
Answered by
Cuvette 246 Moderation Voter
8 years ago

I worked out I was using a HopperBin! Such an idiot. So yeah I changed it to a Tool used a Localscript and modified the script a bit to work with a Tool. But got it working! Thanks guys (:

Ad

Answer this question