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

Script not working but it has no errors? Is it because its a local script?

I tried using print("Clicked") print("10") it prints clicked

mouse.Button1Down:Connect(function()
		print("Clicked")

but not 10?

local num = math.random(1,10)
if num == "10" then
print("10")

These are in the same script which is a local script. Should it be a different script? This is the whole script

local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
		print("Clicked")
		local char = script.Parent.Parent
		local plr = game.Players:GetPlayerFromCharacter(char)
		local leaderstats = plr:FindFirstChild("leaderstats")
		local Gold = leaderstats.Gold
		local humanoid = tool.Parent.Humanoid
		local animation = Instance.new("Animation")
		animation.AnimationId = "http://www.roblox.com/asset/?id=5498807074"
		local animationTrack = humanoid:LoadAnimation(animation)
		animationTrack:Play()
		local num = math.random(1,10)
		if num == "10" then
		print("10")
		Gold.Value = Gold.Value + 1	
	end
end)

1 answer

✓ Accepted answer

you need to check

if num == 10 then -- notice how its not "10" cause "10" is a string while 10 is a number

it would also help to do

print(num)

1 comment

0

ok thanks!

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