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

Works in studio but not in game?

function mask(key)
	if string.lower(key)=='m' and script.Parent.Folder.Value.Value==1 then
		h = Instance.new("Hat")
		p = game.Workspace.Mask2:clone()
		h.Name = "Space Hat"
		p.Parent = h
		p.Position = script.Parent:FindFirstChild("Head").Position
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(2, 0.4, 1) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		p.Anchored = false
		h.Parent = script.Parent
		h.AttachmentPos = Vector3.new(0, -0.5, 0.5)
         h.AttachmentUp = Vector3.new(0, 0.147, 0.989)
		
	end
end
MyMouse=game.Players.LocalPlayer:GetMouse()
MyMouse.KeyDown:connect(mask)

5 comments

0

Did you place the script client-sided? 'cause this looks like it's a local script. However, it looks like you placed it Server-Sided seeing as you're finding a Head of a Character.

0

What does this have to see with serverside scripts? Local scripts can still access the Workspace. It's just that any changes are not replicated to the server...

0

Confusing...

0

Is FilteringEnabled set to true? Because it's a real pain if it is, try looking up RemoteEvents and RemoteFunctions.

0

dude i found the answer!!!

2 answers

due to some roblox newtork loading complications, sometimes stuff may load faster or slower than the others, even if you use a waitForChild(), the way i fixed it is to make a script to disable and enable it to make it work.

Make sure that the script is a "LocalScript" Instead of "Script" only if it has "game.Players.LocalPlayer"

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