Here are the problems with the script above.
connect is deprecated. Use Connect instead. This isn't causing your script to break, but it is good to know, since deprecated methods are no longer supported by roblox.
You wouldn't change the starter gui, as that is what is replicated to the player, not what they see. You would have to go to the player gui.
This would require remote events since a script cannot access the playergui. Otherwise, this will work in studio, but not in game.
The error message occurred because of the equals sign. It thinks that LevelGui is a property of the StarterGui, but it isn't. If you are trying to insert a textlabel, then you would parent the new instance to the LevelGui.
Here is the solution to all four problems.
Put a RemoteEvent called MakeTextLabel inside the ReplicatedStorage
LocalScript inside the gui called LevelGUI
local replicated = game:GetService("ReplicatedStorage")
local createtext = replicated:WaitForChild("MakeTextLabel")
createtext.OnClientEvent:Connect(function()
local textlabel = Instance.new("TextLabel")
textlabel.Parent = script.Parent
end)
Script inside part.
local replicated = game:GetService("ReplicatedStorage")
local createtext = replicated:WaitForChild("MakeTextLabel")
script.Parent.Touched:Connect(function(hit)
local player = nil
for i,v in pairs(game.Players:GetPlayers())do
if v and v.Character and v.Character:IsAncestorOf(hit) then
player = v
break
end
end
if player == nil then return end
createtext:FireClient(player)
end)
2 comments
Read up on Instance.new http://wiki.roblox.com/index.php?title=Instance_(Data_Structure)
Also, you received a helpful comment on your previous (duplicate) question: https://scriptinghelpers.org/questions/54840/my-instancenew-script-in-to-add-an-object-in-the-startergui-isnt-working