When I publish the game and try to play it from the site, none of my LocalScripts are working. I tried putting everything inside of a normal script but nothing worked. I think it has something to do with the code itself, but I have no clue where to start. All my code is placed inside of a LocalScript which is in StarterCharacterScripts. Can anyone explain why? Here is my code right now.
--Getting the Camera
game.Players.PlayerAdded:connect(function(player)
script.LocalScript:clone().Parent = player.CharacterAdded:wait()
end)
--Local Variables
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local Char = player.Character
local Humanoid = Char:WaitForChild("Humanoid")
local Mouse = player:GetMouse()
local lastTapTime = 0
local clicked = false
local Trail = game.ServerStorage.Trail:Clone()
_G.Energy = 100
local Mouse = player:GetMouse()
--Moving the Humanoid
--Double Tap
enabled = true
Mouse.KeyDown:connect(function(key)
if not enabled and clicked then
return
end
if key == "w" and _G.Energy >= 25 then
enabled = false
local function onTap()
if tick() - lastTapTime < 0.2 then
print("double Click!")
clicked = true
--What happends when the user double taps
player.Character.UpperTorso.Velocity = cam.CFrame.lookVector * Vector3.new(1,0,1) * 400
Trail.Parent = Char.HumanoidRootPart
local attachment0 = Instance.new("Attachment", Char.Head)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment", Char.HumanoidRootPart)
attachment1.Name = "TrailAttachment1"
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
wait(0.3)
Trail:Remove()
_G.Energy = _G.Energy - 25
wait(0.5)
end
end
onTap()
lastTapTime = tick()
wait(0.5)
enabled = true
clicked = false
end
end)
--Double Jump
enabled = true
Mouse.KeyDown:connect(function(key)
if not enabled and clicked then
return
end
if key == " " and _G.Energy >= 12.5 then
enabled = false
local function onTap()
if tick() - lastTapTime < 0.2 then
print("double Click!")
clicked = true
--What happends when the user double taps
player.Character.UpperTorso.Velocity = Vector3.new(0, 100, 0)
Trail.Parent = Char.HumanoidRootPart
local attachment0 = Instance.new("Attachment", Char.Head)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment", Char.HumanoidRootPart)
attachment1.Name = "TrailAttachment1"
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
wait(0.3)
Trail:Remove()
_G.Energy = _G.Energy - 12.5
wait(1)
end
end
onTap()
lastTapTime = tick()
wait(0.5)
enabled = true
clicked = false
end
end)
--Repleneshing Energy
for i = 1, math.huge do
wait(0.1)
print(_G.Energy)
if _G.Energy < 100 then
_G.Energy = _G.Energy + 12.5
print(_G.Energy)
wait(2)
end
end

2 comments
hey, could you tell me what error it gives when you test it on a server?
11:04:41 -- ServerStorage is not a valid member of DataModel (next line) Stack Begin (next line) Script 'Workspace.McQuakyDuck.LocalScript', Line 16 (next line) Stack End