Heres an example I made which wouldn't work in play mode. Am I doing everything wrong? Most of my scripts don't work in play mode.
-----------------------------------------------
local user = game.Players.LocalPlayer -- the player
local character = user.Character -- the character
local Tool = script.Parent -- script.parent >:o
local reload = 3 -- reload time between each drink
local debounce = true -- no touchy
local oneuse = false-- if its a one-use item
local timebeforefinish = 3
-----------------------------------------------
function activated()
if not Tool.Enabled then
return
end
if debounce == true then
local anim = character.Humanoid:LoadAnimation(Tool.drink)
anim:Play()
debounce = false
Tool.Handle.gulp:play() -- drink sound
wait(2)
character.Humanoid.Health = character.Humanoid.Health + 50
--- nope ---
if oneuse == true then
onusee()
else
wait(reload)
debounce=true
end
end
end
function equip()
Tool.Handle.equip:play()
end
function unequip()
end
function onusee()
wait(2)
Tool:Destroy()
end
Tool.Activated:connect(activated)
Tool.Equipped:connect(equip)
Tool.Unequipped:connect(unequip)

7 comments
is this a local script
Depends on if you're using LocalScripts or ServerScripts. Here are a couple blog articles that will help explain the difference between online and server mode as well as LocalScripts versus ServerScripts.
https://scriptinghelpers.org/blog/common-mistakes and https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online
explain a little bit more... any errors or anything???
This is a local script and yes its inside of a tool.
Would you like me to give you a better version of your script to work in studio mode as another answer?
Also if you are using a local script, then I would recommend using local functions.