i have a main menu in my startergui that's scripted to spawn in as an elk (or any animal i have planned, but i only have the elk for now). it removes the player model, but when i reset the player doesn't respawn, the elk just perpetually stays there dead. so i wanted to script in a button for someone to press that respawns their player character, so they can click the button again and repeat the cycle.
here's my localscript, as you can see i have the userinputservice and my desired button defined at the top, i just can't find a way to get them to work, all the functions i wrote don't work
local MainMenu = script.Parent local Player = game.Players.LocalPlayer local PlayerModel = Player.Character local uis = game:GetService("UserInputService") local K = Enum.KeyCode.K ----------> BUTTONS local ElkButton = MainMenu.MainFrame.SelHerbivores.Elk ----------> MODELS local Elk = game.ReplicatedStorage.Animals.ElkMale.Adult -------------------------------------------------------------------------------- ElkButton.MouseButton1Click:Connect(function(player) local SpawnElk = Elk:Clone() local OldModel = PlayerModel SpawnElk:SetPrimaryPartCFrame(OldModel.PrimaryPart.CFrame) Player.Character = SpawnElk SpawnElk.Parent = workspace PlayerModel:Remove() MainMenu:Remove() end)
i tried stuff like
uis.InputBegan:Connect(function() K = Elk:Remove() K = Player:LoadCharacter() end)
but that didn't work obviously