Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script only works in studio? mouse.KeyDown function.

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

✓ Accepted answer

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.

1 comment

0

Thank you! Problem solved.

This discussion is preserved as it was. New answers, comments, and votes are closed.