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

Custom team script doesn't work if in the real game?

Hi, there!

I have a problem, Script will work in studio and not in the real game.

--// This is a localscript!
local bill = game:GetService("ServerStorage"):WaitForChild("crobras")

script.Parent.MouseButton1Down:connect(function()
 local plr = game:GetService("Players").LocalPlayer.Character
 local clonedgui = bill:Clone()

print("works")
clonedgui.Parent = game.Workspace[plr.Name].Head
script.Parent.Parent:Destroy()
end)


Need help! :)

3 comments

0

press f9 in real game mode to find any errors lurking around

0

Already did that like 5,000 times!

0

Why do you think you can get to ServerStorage from the client (localscript)?

3 answers

Server Storage only goes to the server, like the name implies. Instead, use ReplicatedStorage. Also, READ MY BIO!

Okay, so I guess you're trying to make a custom name ontop of the player's head by clicking a GUI.

To me, it's easier by putting the BillboardGui somewhere inside the ScreenGui. BillboardGui only works when it's inside a Part

This is the recreated version of your script:


-- this local script must be inside ScreenGui

local plr = game.Players.LocalPlayer
local b1 = script.Parent.Parent:WaitForChild('BillboardGui')

script.Parent.MouseButton1Click:connect(function()
	local b2 = plr.Character.Head:FindFirstChild('BillboardGui')	
	if b2 then	-- if the Billboard is already inside, it will destroy and replace the new one		
		b2:Destroy()
		wait(.1)
		b1:Clone().Parent = plr.Character.Head
		print('cloned')
	else	-- if the Billboard isn't inside, it will clone and put inside the player's head					
		b1:Clone().Parent = plr.Character.Head
print('cloned')
	end
end)

LocalScript, using ServerStorage? You see what doesn't work there?

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