I've tried everything. Nothing makes it work online. Yes, this is a localscript inside a HopperBin.
plr = game.Players.LocalPlayer mouse = plr:GetMouse() chr = plr.Character o = false script.Parent.Selected:connect(function() plr.PlayerGui.codes.TextLabel.Text = "Press M to see what magics you have unlocked!" mouse.KeyDown:connect(function(key) if key == "m" then if plr.PlayerGui.Magics.Frame.Visible == false then plr.PlayerGui.Magics.Frame.Visible = true plr.PlayerGui.codes.TextLabel.Text = "Remember to say !save to save tools, and !load to load tools!" elseif plr.PlayerGui.Magics.Frame.Visible == true then plr.PlayerGui.Magics.Frame.Visible = false end elseif key == plr.PlayerGui.Magics.Frame.FBK.Text then if o == false then o = true for i = 1,1 do game:GetService("Chat"):Chat(chr.Head, "Fireball!") local p = Instance.new("Part", workspace) game.Debris:AddItem(p, 5) p.BrickColor = BrickColor.new("Bright red") p.Transparency = 0.3 p.TopSurface = "Smooth" p.BottomSurface = "Smooth" p.Size = Vector3.new(10,10,10) p.Shape = "Ball" p.Anchored = false p.CanCollide = false local o = Instance.new("Part", workspace) game.Debris:AddItem(o, 5) o.BrickColor = BrickColor.new("Deep orange") o.Transparency = 0.2 o.TopSurface = "Smooth" o.BottomSurface = "Smooth" o.Size = Vector3.new(8,8,8) o.Shape = "Ball" o.Anchored = false o.CanCollide = false local w = Instance.new("Weld", o) w.Part0 = o w.Part1 = p local f = Instance.new("Fire", p) f.Heat = 20 f.Size = 20 p.CFrame = chr.Torso.CFrame * CFrame.new(0,0,-5+-i) local ow = Instance.new("StringValue", p) ow.Name = "Owner" ow.Value = plr.Name local y = Instance.new("BodyVelocity") y.maxForce = Vector3.new(math.huge, math.huge, math.huge) y.velocity = plr.Character.Torso.CFrame.lookVector*80 y.Parent = p local m = Instance.new("Message", plr.PlayerGui) m.Text = "Sorry! The fireball skill is still under developement, It will do no damage." wait(2) m:Destroy() end wait(0.5) o = false end end end) end)
This is what you did wrong:
When going for the key, you did not key = key:lower()
. It is very important, because by default, the keys are uppercase.
So:
mouse.KeyDown:connect(function(key) key = key:lower() if key == "m" then -- code end end
A useful way to debug is to insert print()s throughout the script. For example:
"Why won't my script work?"
local num = 5 if num == 4 then -- code end
"Adding prints..."
print("ok") local num = 5 print("ok2") if num == 4 then print("ok3") end
"Oh, that's right. I'm looking for 4, instead of 5!"