I'm new to scripting, and I've been watching various tutorials to try and make a script that uses remote events to trigger an overhead GUI (a title) to appear over a single person's head permanently that everyone else can see.
The way I want it to trigger is through touching a morph pad, which is just a Part with several scripts inside it for welding various parts to the character.
I'm still inexperienced, and I apologize in advance.
The two relevant scripts (a localScript and a Script) i have so far look like this:
LocalScript (parent is Morph, the pad, which is part of a model being part of Workspace):
script.Parent.Touched:Connect(onTouch) function onTouch(hit) if hit.Parent:FindFirstChild("Humanoid") then local Debounce = false if Debounce == false then Debounce = true game.ReplicatedStorage.RemoteEvent:FireServer() print ("Remote Event has fired.") wait(0.1) Debounce = false end end end script.Parent.Touched:connect(onTouch)
Script (located in ServiceScriptService currently):
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() local billboardgui = game.GetService("ReplicatedStorage"):WaitForChild("BillboardGui") local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local clonedgui = billboardgui:Clone() clonedgui.TextLabel.Text = "~Black Queen~" clonedgui.TextLabel.TextColor3 = Color3.fromRGB(252,0,10) clonedgui.TextLabel.TextStrokeColor3 = Color3.fromRGB(103,0,1) clonedgui.TextLabel.Font = "Bodoni" clonedgui.Parent = game.Workspace.WaitForChild(player.Name).Head print("Event has fired.") end)
There was no errors that popped up in the console, but the print() events did not fire, and the overhead gui didn't appear over my head when I touched the pad.
Again, I apologize for any problems I have that could have been prevented.
Thank you for reading.
It is important to note that you can not use LocalScripts in parents that are not client replicated. Since you have a LocalScript inside of a Part that is inside of a Model that is inside of Workspace, the LocalScript will not run since it is not being run from the client. In order to solve the problem, there should be a Script inside of the part instead of a LocalScript.
Furthermore, since you are using a Script to communicate with another Script, you need to use a BindableEvent rather than a RemoteEvent. RemoteEvents are used to communicate between the Client and Server, but in this case, you are only communicating between two Scripts.
Script inside of part:
local Part = script.Parent local Debounce = false Part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil and not Debounce then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) Debounce = true game.ReplicatedStoarge.BindableEvent:Fire(Player) print("Bindable Event was fired") wait(0.1) Debounce = false end end)
Script Inside of ServerScriptService:
game.ReplicatedStorage.BindableEvent.Event:connect(function(Player) local BillboardGui = game.ReplicatedStorage:WaitForChild("BillboardGui"):clone() local Char = Player.Character BillboardGui.TextLabel.Text = "~Black Queen~" BillboardGui.TextLabel.TextColor3 = Color3.fromRGB(252, 0, 10) BillboardGui.TextLabel.TextStrokeColor3 = Color3.fromRGB(103,0,1) BillboardGui.TextLabel.Font = "Bodoni" BillboardGui.Parent = Char.Head print("Event was fired") end)
I hope that helps! :)