I have this gear that if you equip it, your character will have a highlight. I play-tested my game, gave myself the gear, but no highlight. Checked the Developer Console, no errors or warnings.
I believe that my LocalScript is somewhat of the problem, but I can’t be the one that can tell that since I’m getting back into coding on Roblox. Would anyone let me know what the issue is and potentially fixes that I can do?
Both ServerScript and LocalScript will be shown below.
ServerScript:
--// Variables
local Highlight = script.Highlight
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Remote = Remotes.SpecialTitleEquipped
--// Script
Remote.OnServerEvent:Connect(function(player, data)
if data == "equipped" then
local HighlightClone = Highlight:Clone()
HighlightClone = player.Character
elseif data == "unequipped" then
local HighlightClone = player.Character:WaitForChild("Highlight")
if HighlightClone.Parent == player.Character then
HighlightClone:Destroy()
end
end
end)
LocalScript
--// Variables
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Tool = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
--// Script
Tool.Equipped:Connect(function()
Remotes.SpecialTitleEquipped:FireServer("equipped")
end)
Tool.Unequipped:Connect(function()
Remotes.SpecialTitleEquipped:FireServer("unequipped")
end)
Huh? Isn’t all you need in that case to set the Hightlight’s Parent to t he Character? Because all youre doing is trying to make the Highlight your Character, which does not really make much sense haha. Lmk if this helped and if that’s what u needed.
Hi so I just tried it out myself and it works for me. All I changed was 1 line feel free to try it out yourself.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Remote = Remotes.SpecialTitleEquipped
--// Script
Remote.OnServerEvent:Connect(function(player, data)
print(data)
if data == "equipped" then
print("True")
local HighlightClone = script.Highlight:Clone()
HighlightClone.Parent = player.Character
elseif data == "unequipped" then
local HighlightClone = player.Character:WaitForChild("Highlight")
if HighlightClone.Parent == player.Character then
HighlightClone:Destroy()
end
end
end)```