The Player:LoadCharacter()
basically respawns the player, making them able to move & jump again.
Thatâs if they have not spawned yet, but if I make it teleport then they wonât need to spawn in.
The LoadCharacter
Player
function creates a new character for the player, removing the old one. It also clears the playerâsBackpack
andPlayerGui
.
This is useful in cases where you want to reload the character without killing the player, such as when you want to load a new character appearance after changing the playerâs
Player.CharacterAppearance
.
Also, I have stumbled upon this weird code inside of your LocalScript
local spawnCharacterEventFind = ReplicatedStorage:FindFirstChild("spawnPlayer")
if spawnCharacterEventFind then
spawnCharacterEventFind.Parent = nil
spawnCharacterEvent = spawnCharacterEventFind
end
It basically deletes the RemoteEvent required, can you add a print("Hello! It works.")
after Line 21 in the ServerScriptService script? To see if it actually sent a request to the server?
Like this?
Would I delete that part of the script you saw?
Yes, now see if it prints when you press Play.
If it does not print, then try doing so (It is located at line 64 inside the LocalScript for me)
Still has not worked, even after removing it. Are you able to make a script so the player spawns in a box far away and when they click play they teleport to the spawnlocations?
Alright, give me some minutes.
I will make the area where they first spawn at before clicking play. and thank you
I have added an area for them to spawn before. Is right under the map good or should it be far?
Under the map should be good, can you give me the position of the cage?
Here is the position of the part that they will first spawn at: (-9.977, -24.409, 33.768)
Here are the spawnlocations after they hit play: (30.831, 4.5, 10.82) (31, 4.5, 56) (26.706, 4.5, 94.894) (33.078, 4.5, 157.899) (-7, 4.5, 160) (-85.1, 4.5, 94.357) (-78.671, 4.5, 46.257) (-78.75, 4.5, -0.25)
------ PUT THIS INSIDE A SERVERSCIRPT -------
local Pos = CFrame.new(-9.977, -24.409, 33.768)
game:GetService("Players").PlayerAdded:Connect(function(plr)
local Character = plr.Character or plr.CharacterAdded:Wait()
Character:WaitForChild("HumanoidRootPart").CFrame = Pos
end)
------ REPLACE THIS CODE BELOW WITH THE LOCALSCRIPT ONE ------
local StarterGui = game:GetService("StarterGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local camera = game.Workspace.Camera
StarterGui:SetCore("ResetButtonCallback", false)
local setting = {}
setting.cutsceneTime = 2;
setting.cutscenePrefix = "Test";
setting.tweenInfo = TweenInfo.new(
setting.cutsceneTime,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
);
setting.TweenObjectsLocation = game.Workspace;
setting.myMethod = true; -- By using my method there will be a white flash tween which will tween a new frame to fully visible, change menu frame visible to false and then load to player
local inMenu = true
local menuVisible = true
local scenePlaying = false
local spawnCharacterEvent = nil
function spawnPlr()
menuVisible = false -- DO NOT DELETE THIS LINE! put it after the line where you change the menu frame visible to false
StarterGui:SetCore("ResetButtonCallback", true) -- Keep this line with the line above it
local spawnCharacterEventFind = ReplicatedStorage:FindFirstChild("spawnPlayer")
end
function tween(part1,part2)
scenePlaying = true
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, setting.tweenInfo, {CFrame = part2.CFrame})
tween:Play()
local finishFunc
finishFunc = tween.Completed:Connect(function()
scenePlaying = false
finishFunc:Disconnect()
finishFunc = nil
end)
repeat task.wait() until scenePlaying == false or inMenu == false
if inMenu == false then
repeat task.wait() until menuVisible == false
camera.CameraType = Enum.CameraType.Custom
end
end
task.wait(2)
local ObjectsToTween = {}
function addTweenObject(index, obj)
ObjectsToTween[index] = obj
end
for i,v in pairs(setting.TweenObjectsLocation:GetChildren()) do
if v.Name:lower():find(setting.cutscenePrefix:lower()) then
if #v.Name > #(setting.cutscenePrefix) then
local number = v.Name:sub(#(setting.cutscenePrefix) + 1, #v.Name)
if tonumber(number) ~= nil then
addTweenObject(tonumber(number), v)
end
end
end
end
function StartTween()
for i,v in pairs(ObjectsToTween) do
if not inMenu then break end
if i < #ObjectsToTween then
tween(v, ObjectsToTween[i + 1])
end
end
end
coroutine.wrap(function()
while inMenu do
StartTween()
task.wait()
end
end)()
local function PlayButton()
if not inMenu then return end
inMenu = false
if setting.myMethod then
local GUI = script.Parent:FindFirstAncestorOfClass("ScreenGui")
if GUI then
local FlashFrame = Instance.new("Frame")
FlashFrame.Name = "FlashFrame"
FlashFrame.AnchorPoint = Vector2.new(0.5, 0.5)
FlashFrame.Position = UDim2.new(0.5, 0, 0.5, 0)
FlashFrame.Size = UDim2.new(1, 0, 1, 0)
FlashFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
FlashFrame.BorderSizePixel = 0
FlashFrame.BackgroundTransparency = 1
FlashFrame.ZIndex = 999999999
FlashFrame.Parent = GUI
local Visibility = true
local Duration = 2
local function createNewTween(visible)
Visibility = visible
local newTween = TweenService:Create(
FlashFrame,
TweenInfo.new(
Duration,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out
),
{
BackgroundTransparency = Visibility == true and 0 or 1
}
)
return newTween
end
local TweenObj = createNewTween(true)
TweenObj:Play()
TweenObj.Completed:Wait()
TweenObj = createNewTween(false)
local MenuFrame = nil -- Must specify
if MenuFrame ~= nil then
MenuFrame.Visible = false
else
MenuFrame = GUI
GUI.Enabled = false
end
spawnPlr()
TweenObj:Play()
inMenu = false
TweenObj.Completed:Wait()
llocal TableOfPositions = {Pos1 = Vector3.new(30.831, 4.5, 10.82), Pos2 = Vector3.new(31, 4.5, 56), Pos3 = Vector3.new(26.706, 4.5, 94.89), Pos4 = Vector3.new(33.078, 4.5, 157.899), Pos5 = Vector3.new(-7, 4.5, 160), Pos6 = Vector3.new(-85.1, 4.5, 94.357), Pos7 = Vector3.new(-78.671, 4.5, 46.257), Pos8 = Vector3.new(-78.75, 4.5, -0.25)}
local RandomIndex = math.random(1,8)
game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(TableOfPositions["Pos"..RandomIndex])
FlashFrame:Destroy()
end
return
end
end
script.Parent.MouseButton1Click:Connect(PlayButton)
This should hopefully work now.
Replace this with the one I have?
Replace the code below with the LocalScript in the Button
Wait this is the serverscriptservice I thought
What does this have to do with the local script?