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
10 years ago

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

01player=script.Parent.Parent.Parent.Parent
02mouse=player:GetMouse()
03frame=script.Parent
04text=script.Parent.text
05text.Text=("Welcome to "..script.Parent.Parent.Name)
06 
07mouse.KeyDown:connect(function(key)
08    key=key:lower()
09    if key=="m" then
10 
11--lots of stuff
12 
13    end
14end)

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:

01flagclone=game.ServerStorage.flag
02for o,p in pairs(flagclone:getChildren()) do
03    p:Clone()
04    p.Parent=game.Workspace
05    if p:IsA("Part") then
06    p.Position=player.Character.Head.Position
07end end
08script.Disabled=true
09print("pressed ("..key..")")
10for i=1,0,-0.01 do
11frame.BackgroundTransparency=i
12text.TextTransparency=i
13wait()
14end
15wait(1)
View all 45 lines...

-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
10 years ago

Your problem is this line here:

1flagclone=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 — 10y
Ad

Answer this question