Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script Works In Studio But Not Online?

Asked by 8 years ago

Problem: As the title says, script works in Studio but not online, no errors in output

player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local Tool = leaderstats:WaitForChild('WoodenSword')
local cl = game.ReplicatedStorage:FindFirstChild("WoodenSword")
local cl2 = cl:Clone()
local Bought = script.Parent:WaitForChild('HasBought')
local CurImage = script.Parent.Parent:WaitForChild('ImageLabel')
local Equiped = false
local UnequipedColor = BrickColor.new("Really red")
local UnequipedColor2 = UnequipedColor.Color
local EquipColor = BrickColor.new("Lime green")
local EquipColor2 = EquipColor.Color
local AnyEquiped = script.Parent.Parent.Parent.Parent.MeleeEquip
local NA = script.Parent.NA
local Player = game.Players.LocalPlayer
local Character = player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild('Humanoid')
local Type = script.Parent.Parent.Parent.Parent.Character.Melees.ImageLabel
local sound = script.Parent.Equip

function Check()
    if Bought.Value == true and Equiped == false and AnyEquiped.Value == false then

        Type.Image = script.Parent.Parent.ImageLabel.Image
        cl2.Parent = player.Backpack    
        script.Parent.BackgroundColor3 = EquipColor2
        AnyEquiped.Value = true 
        Equiped = true
        script.Parent.Text = 'UnEquip'
        sound:Play()

    elseif  Bought.Value == true and Equiped == true  then
        Humanoid:UnequipTools()
        wait(.1)
        Type.Image = NA.Value
        player.Backpack:findFirstChild("WoodenSword"):remove()
        script.Parent.BackgroundColor3 = UnequipedColor2
        AnyEquiped.Value = false
        Equiped = false
        script.Parent.Text = 'Equip'
        sound:Play()

    end
end




script.Parent.MouseButton1Click:connect(Check)
0
Try printing at different points in the script to see where it's stopping. Or, please indent your code so I have the patience to read it. Pyrondon 2089 — 8y
0
it is indented TheTermaninator 45 — 8y
0
If this is a server script then your problem begins at line 1. You cannot access the local player using that method in a server script. I didn't see anywhere that you used serverstorage so that rules out one of the possible problems I was going to list. If you are using server storage and I don't see it: If this is a local script and you are trying to access server storage then your problem would AZDev 590 — 8y
0
begin there. ServerStorage is not accessible from a local script. Hope this helps. AZDev 590 — 8y
View all comments (2 more)
0
this is a local script. TheTermaninator 45 — 8y
0
Ya, a lot of the time regular scripts work in Studio but not in servers because they are meant to be local scripts GShocked 150 — 8y

Answer this question