Why does the button work only once? The RemoteEvent is fine and the server morph logic works every time. How can I make the button always fire the RemoteEvent, even after the player's Character has changed?
I have buttons in a ScreenGui that send a RemoteEvent to the server to morph the character.
It works the first time, but after the player morphs once (Character changes), clicking the button again does nothing—no print, no event sent.
The buttons themselves are still in the GUI; the LocalScript is not destroyed.
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local buttonsFolder = playerGui:WaitForChild("MorphList"):WaitForChild("MorphFrame")
local eventsFolder = RS:WaitForChild("Events"):WaitForChild("Morph")
for _, button in ipairs(buttonsFolder:GetChildren()) do
if button:IsA("TextButton") then
local morphName = button.Name
button.MouseButton1Click:Connect(function()
local event = eventsFolder:FindFirstChild("Morph_" .. morphName)
if event then
event:FireServer(morphName)
print("Morph 이벤트 전송:", morphName)
else
warn("RemoteEvent가 존재하지 않음:", morphName)
end
end)
end
end
player.CharacterAdded:Connect(function(newChar)
print("새 Character 감지됨:", newChar.Name)
end)
** You are now Level 1! **