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

Why won't my script work after the game is published?

Asked by 6 years ago
Edited 6 years ago

Here is my code.

what i don't understand is i even took out everything except closing the gui, and even that didn't work. so i am scrambling my brains here!

script.Parent.MouseButton1Click:connect(function()

--local m = Instance.new("Message") --m.Text = ("This is a Test") --wait(3) --m:remove()

local equipping = script.Parent.Parent.Equipping.Value local storage = game.ServerStorage local player = game.Players.LocalPlayer local plr = player.Name

player.CameraMode = "LockFirstPerson"

for a, b in pairs (storage:GetChildren()) do if b.ClassName == "Tool" and b.Name == tostring(equipping) then local newEquip = b:Clone() newEquip.Parent = player.Character end
end

script.Parent.Parent.Enabled = false script.Parent.Modal = false

end)

The basis is it will equip the item, leave and lock you in first person view with that tool equipped.

I have tried both a local and normal script just to test and neither are working as in studio. not sure what if my mind is just missing something or what not. Need some fresh eyes.

Thanks in advance.

0
You're using deprecated code, and using Strings in place of Enumerations. And please use code blocks. User#19524 175 — 6y
0
You're also wrapping things in () that is not okay. User#19524 175 — 6y
0
The hell you on about ._. arshad145 392 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
-- LocalScript
script.Parent.MouseButton1Click:Connect(function() -- use :Connect
    local plr = game:GetService("Players").LocalPlayer
    local screen = Instance.new("ScreenGui",plr.PlayerGui) -- Messages are deprecated.
    screen.Name = "MessageGUI" 
    local msg = Instance.new("TextLabel",screen)
    msg.Name = "Message"
    msg.Size = UDim2.new(0, 600, 0, 400)
    msg.Position = UDim2.new(0.5, -300, 0.5, -200)
    msg.Text = "This is a test" -- See i didn't say ' ("This is a test") '?
    wait(3)
    screen:Destroy() -- :remove() is deprecated

    local storage = game:GetService"ReplicatedStorage" -- Server Storage is inaccessible from local scripts.
    plr.CameraMode = Enum.CameraMode.LockFirstPerson -- Don't say "LockFirstPerson"
    for a, b in pairs(storage:GetChildren()) do
        if b:IsA"BackpackItem" then-- a tool
            local newEquip = b:Clone() -- your code made no sense tbh so sorry
            newEquip.Parent = plr.Backpack
            plr.Character.Humanoid:EquipTool(plr.Backpack[newEquip.Name])
            -- done
        end
    end
end)
Ad

Answer this question