Yes I've read https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online
When this script is activated, It should be creating a remote event which is then fired, creating a new character for the player to use. However, when I test this on a server, the remote event returns nil.
--Edit-- Now the event just isn't created
Inside of a Server Script
wait(.1)
while not player do
wait()
player = game.Players:GetPlayerFromCharacter(script.Parent)
end
function onSpawn()
local char = game.ReplicatedStorage["New Player"]:Clone()
local SpawnLocation = game.Workspace.SpawnLocation2
char.Parent = workspace
char.Name = player.Name
char:MoveTo(SpawnLocation.Position)
local prevChar = player.Character
wait()
player.Character = char
prevChar:Destroy()
if char:FindFirstChild("Humanoid") then
char.Humanoid:Destroy()
end
local human = Instance.new("Humanoid", char)
char.Archivable = false
human.WalkSpeed = 8
wait(1)
human.Died:connect(function()
wait(1)
onSpawn()
wait(.01)
player.Character.Humanoid.Running:connect(onGround)
end)
--Player Values
local move_left = false
local move_right = false
local already_ran = false
local grounded = false
local idleAnimation = Instance.new("Animation")
idleAnimation.AnimationId = "rbxassetid://317651678"
local runningAnimation = Instance.new("Animation")
runningAnimation.AnimationId = "rbxassetid://319211805"
local R2 = Instance.new("Animation")
R2.AnimationId = "rbxassetid://312976450"
local I2 = Instance.new("Animation")
I2.AnimationId = "rbxassetid://313623015"
local J = Instance.new("Animation")
J.AnimationId = "rbxassetid://326922088"
function playAnimation(parent)
local AnimTrack = player.Character.Humanoid:LoadAnimation(parent)
AnimTrack:Stop()
wait(.01)
AnimTrack:Play()
end
function onGround(speed)
if grounded == false then
grounded = true
end
if speed > 1 --and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Offensive")
then
if already_ran == false then
already_ran = true
playAnimation(runningAnimation)
end
--elseif speed > 1 and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Idle") then
--if already_ran == false then
--already_ran = true
--playAnimation(R2)
elseif speed > 0 and already_ran == true --and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Offensive")
then
already_ran = false
playAnimation(idleAnimation)
--elseif speed > 0 and already_ran == true and player.PlayerGui.SwordPlaySystemMK2.CombatStage.Value == ("Idle") then
--already_ran = false
--playAnimation(I2)
end
end
end
event = Instance.new("RemoteEvent") -- creates the event object
event.Parent = game.ReplicatedStorage -- puts the event into the ReplicatedStorage
event.Name = "ServerEvent" -- giving a name to the event so we can fire it specifically elsewhere
event.OnServerEvent:connect(function() -- define the function that will be called when the event is fired
onSpawn()
player.Character.Humanoid.Running:connect(onGround)
game.Workspace.BasePlate.BrickColor = BrickColor.Random()
end)
Inside of a Local Script within a GUI button
local player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:connect(function()
local S = game.ReplicatedStorage.SpawnScript:Clone()
S.Parent = player.Character
S.Disabled = false
wait(1)
local e = game.ReplicatedStorage:WaitForChild("ServerEvent")
e:FireServer()
end)
Thanks in advance for any help.

1 comment
The issue is, the event still doesn't seem to be created at all.