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

Script only works in studio? mouse.KeyDown function.

Asked by
Qorm 100
9 years ago

Not too sure what's going on. The script is Local and I've also tried regular.

player=script.Parent.Parent.Parent.Parent
mouse=player:GetMouse()
frame=script.Parent
text=script.Parent.text
text.Text=("Welcome to "..script.Parent.Parent.Name)

mouse.KeyDown:connect(function(key)
    key=key:lower()
    if key=="m" then

--lots of stuff

    end
end)

Ok. I know this is my second question yet in 24 hours, but this frustrates me. I can't figure out why it works for other people but not me?

EDIT: So apparently everything else works except the starting GUI. Here's the part of the script that DOESN'T load:

        flagclone=game.ServerStorage.flag
        for o,p in pairs(flagclone:getChildren()) do
            p:Clone()
            p.Parent=game.Workspace
            if p:IsA("Part") then
            p.Position=player.Character.Head.Position
        end end
        script.Disabled=true
        print("pressed ("..key..")")
        for i=1,0,-0.01 do
        frame.BackgroundTransparency=i
        text.TextTransparency=i
        wait()
        end
        wait(1)
        for i=0,1,0.05 do
        text.TextTransparency=i
        wait()
        end
        wait(0.1)
        text.Text=("The current Version is: "..script.Parent.Parent.version.Value.."!")
        for i=1,0,-0.05 do
        text.TextTransparency=i
        wait()
        end
        wait(2)
        for i=0,1,0.05 do
        text.TextTransparency=i
        wait()
        end
        wait(0.1)
        text.Text="Enjoy!"
        for i=1,0,-0.1 do
        text.TextTransparency=i
        wait()
        end
        wait(2)
        for i=0,1,0.025 do
        frame.BackgroundTransparency=i
        text.TextTransparency=i
        wait()
        end
        wait(0.2)
        welcomesound:Stop()
        welcomesound:remove()

-this works in studio, not in online mode.

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Your problem is this line here:

flagclone=game.ServerStorage.flag

Your code, to work, has to be in a LocalScript, which do not have access to ServerStorage.

Put flag in ReplicatedStorage instead.

0
Thank you! Problem solved. Qorm 100 — 9y
Ad

Answer this question