Not teleporting root

I am using a play button that sends to the server so it can check for classes, and team, etc, and if its on blue it goes to the blue spawn, if its on red it goes to red spawn. (It doesn’t give any weapons either?)

What am I doing wrong here?

local spn = game.ReplicatedStorage.Spawn

spn.OnServerEvent:Connect(function(plr,class)
	local bpk = plr.Backpack
	local char = plr.Character
	local ars = game.ServerStorage.Arsenal
	
	local redp = workspace.Map:FindFirstChild("redP")
	local blup = workspace.Map:FindFirstChild("bluP")
	
	if class.Value == "Assault" then
		local a1 = ars.SMG:Clone()
		local a2 = ars.PISTOL:Clone()
		local a3 = ars.GRN:Clone()
		
		a1.Parent = bpk
		a2.Parent = bpk
		a3.Parent = bpk
		
		if plr.Team == "Rebels" then
			char.HumanoidRootPart.Position = redp.Position
		elseif plr.Team == "Defenders" then
			char.HumanoidRootPart.Position = blup.Position
		end
		
	elseif class.Value == "Rifleman" then
		local a1 = ars.AR:Clone()
		local a2 = ars.PISTOL:Clone()
		local a3 = ars.GRN:Clone()

		a1.Parent = bpk
		a2.Parent = bpk
		a3.Parent = bpk
		
		if plr.Team == "Rebels" then
			char.HumanoidRootPart.Position = redp.Position
		elseif plr.Team == "Defenders" then
			char.HumanoidRootPart.Position = blup.Position
		end
		
	elseif class.Value == "Raider" then
		local a1 = ars.SHOTGUN:Clone()
		local a2 = ars.PISTOL:Clone()
		local a3 = ars.GRN:Clone()

		a1.Parent = bpk
		a2.Parent = bpk
		a3.Parent = bpk
		
		if plr.Team == "Rebels" then
			char.HumanoidRootPart.Position = redp.Position
		elseif plr.Team == "Defenders" then
			char.HumanoidRootPart.Position = blup.Position
		end
		
	elseif class.Value == "Marksman" then
		local a1 = ars.SNIPER:Clone()
		local a2 = ars.PISTOL:Clone()
		local a3 = ars.GRN:Clone()

		a1.Parent = bpk
		a2.Parent = bpk
		a3.Parent = bpk
		
		if plr.Team == "Rebels" then
			char.HumanoidRootPart.Position = redp.Position
		elseif plr.Team == "Defenders" then
			char.HumanoidRootPart.Position = blup.Position
		end
		
	elseif class.Value == "Rocketeer" then
		local a1 = ars.RKTL:Clone()
		local a2 = ars.PISTOL:Clone()
		local a3 = ars.GRN:Clone()

		a1.Parent = bpk
		a2.Parent = bpk
		a3.Parent = bpk
		
		if plr.Team == "Rebels" then
			char.HumanoidRootPart.Position = redp.Position
		elseif plr.Team == "Defenders" then
			char.HumanoidRootPart.Position = blup.Position
		end
		
	end
end)

Possibly change the variable ‘char’ to ‘character’ because ‘char’ refers to a type of string manipulation.

1 Like

Done, it doesn’t make a difference.

If it isn’t giving weapons then this is the problem:

if class.Value == "Assault" then

Edit: Nevermind that’s probably not it, let me read more into your code, give me a sec.

At the start of your connect function can you print this:

print(tostring(class.Value))

Can you make the event print something to see if the remote event is actually being fired at all?

I made it so it prints the class (it printed the right one) and it said it fired and got variables.

So currently you have this:

if class.Value == "Assault" then

Could you change it to this:

if tostring(class.Value) == "Assault" then

It says none for some reason? I originally tried just using class.Value instead of tostring

By ‘none’ do you mean nil?

And do you get ‘nil’ from tostring or from not using it?

No it says “None” that’s what the value is set to by default

The issue isn’t from the script you submitted, it’s from whatever is firing the RemoteEvent. If you change the value ‘None’ to ‘Rebels’ it’ll work.

Unless there’s more going on but I doubt it.

1 Like

This is the send local script.

local class = script.Parent.Parent.Class
local spn = game.ReplicatedStorage.Spawn
script.Parent.MouseButton1Click:Connect(function()
	spn:FireServer(class)
	script.Parent.Parent.Enabled = false
	print(class.Value)
end)

Found a really weird problem it’s the code that changes the values when you press a button, they don’t change the value in a server nor local script.

Instead of sending over a value, replace everything to just strings. For instance:

local class = script.Parent.Parent.Class
local spn = game.ReplicatedStorage.Spawn
script.Parent.MouseButton1Click:Connect(function()
	spn:FireServer(tostring(class.Value))
	script.Parent.Parent.Enabled = false
end)

You’re going to have to make some adjustments in the server script but it shouldn’t be too hard.

I’m not sure what you mean, but is it fixable?

I don’t know, it doesn’t change the value.

This is one of the scripts that makes it change values.

local class = script.Parent.Parent.Class
script.Parent.MouseButton1Click:Connect(function()
	class.Value = "Rifleman"
end)

I’m not sure what the error is, sorry.

It’s not changing the value, it just keeps it at None.