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

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

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)

10 comments

0

Do you get any errors?

0

I get nothing at all from it

0

Well I have no idea..

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.

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.

0

It doesn't print anything past the first function or even the first function infact

0

maybe it's the WaitForDataReady()??

0

I've tried removing it and assigning it to other things, not happening :/

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.

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 (:

1 answer

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 (:

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