How would i make an Equip and Unequip system with the data also being sent to the game level (any level ex: level 1 )

  1. What do you want to achieve?
    If the player equips a combination of either a suppressors and gun skin 1 or no suppressor and gun skin 2 or just a suppressor, how would i do that and send the data to another game aka level 1 or something so that i know what to give the player in terms of what combination they have

  2. What is the issue?
    i have no idea how to make it but it the screen looks like this

  3. What solutions have you tried so far?
    what i want to try and achieve is too specific and i cant find anything. im also fairly new to scripting

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Teleportation data: TeleportService | Roblox Creator Documentation

thanks ill try to understand it

You can use this to help your particular issue. It sends tools to a private server, you can change that to place instead. It made need some modification however: Help with TeleportData

thanks ill try look into that one too

I would recommnend using values for the system like, if the player has a supressor just make a value and save it to datastore or whatever. You could do all of this to datastore. As long as the two places are under the same game.

ya, when i made the first level i realized something was wrong and apparently its supposed to be in the game in asset manager so now everything should be set up correctly

how would i like create data to send when the event happens? the script i have right now is for changing the guns in a viewportframe using a local script

game.ReplicatedStorage.ChangeWeaponSuppressedGalaxy.OnClientEvent:Connect(function(Player)
	print("Attempt 1")

	Copy1.Parent = viewport.M4A1Folder
	Copy4.Parent = viewport.M82Folder
	Copy7.Parent = viewport.VectorFolder
	viewport.M4A1Folder.M4A1.Parent = ReplicatedStorage
	viewport.M4A1Folder["M4A1 Suppressed"].Parent = ReplicatedStorage
	viewport.M4A1Folder["M4A1 Galaxy"].Parent = ReplicatedStorage
	viewport.M82Folder.M82.Parent = ReplicatedStorage
	viewport.M82Folder["M82 Suppressed"].Parent = ReplicatedStorage
	viewport.M82Folder["M82 Galaxy"].Parent = ReplicatedStorage
	viewport.VectorFolder.Vector.Parent = ReplicatedStorage
	viewport.VectorFolder["Vector Suppressed"].Parent = ReplicatedStorage
	viewport.VectorFolder["Vector Galaxy"].Parent = ReplicatedStorage
	print("Changed To Suppressed Galaxy")

end)

Like data for datastore? Or Data for teleport data

at the end of the script i would fire an event for a server script but what would i put in the server script to send the information to the level so that it would configure the level with what they have attached?

after reading it again, i can say for the teleport data

Off-topic, but you need to organize that better so its more editable in the future…

How would i organize it better? cause i dont know

Try using functions. This page explains how to completely utilize them, and you can envision where you could use them, like, making a function to move everything to ReplicatedStorage. You could also use loops to move everything easily, like so:

for _, v in pairs(gun folder:GetChildren()) do
v.Parent = ReplicatedStorage
end
1 Like

I would not reccomend doing this, I would reccomend creating a temporary DataStore listing, with the PrivateServer teleport ID, containing all tools. Then, delete it afterwards. It may cause a little bit of slow down in your game, but it’s the most secure way to do it right now.

TeleportData can be manipulated.

Thanks thats gonna help with a lot in the future.

Honestly I haven’t even gotten to anywhere yet, neither do I know what I should do

Set up a datastore as you normally would, post data to it, then delete the data after it is read from in the teleported private server.

I have no idea how to do any of that is the problem. Where would i start?

I’m having a hard time understand your script but I’ve made a system that should work.

--Server Script IN THE LOBBY - aka the place that teleports you to the other.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.Event -- Put your event directory here
local teleportOptions = Instance.new("TeleportOptions")
local Player = game:GetService("Players")

Player.PlayerAdded:Connect(function(Player) 
local M4A1 = Instance.new("StringValue", Player)
M4A1.Name = "M4A1"
M4A1.Value = "Normal"

local M82 = Instance.new("StringValue", Player)
M82.Name = "M82"
M82.Value = "Normal"

local Vector = Instance.new("StringValue", Player)
Vector.Name = "Vector"
Vector.Value = "Normal"
end)

Event.OnServerEvent:Connect(function(player)

GunData = {
M4A1 = player.M4A1.Value
M82 = player.M82.Value
Vector = player.Vector.Value
}

teleportOptions:SetTeleportData(GunData)
TeleportService:TeleportAsync(Put the teleportId here, {player}, teleportOptions)

end)
-- local script IN THE LOBBY - aka the place that teleports you to the other.

local player = game.Players.LocalPlayer
local M4A1 = player.M4A1
local M82 = player.M82
local Vector = player.Vector
local Button = script.Parent.Button -- Whatever the directory
local PlayButton = script.Parent.PlayButton

-- Here is an example of changing the value
Button.MouseButton1Click:Connect(function()
if M4A1.Value = "Suppressed" then
M4A1.Value = "Normal"
Button.Text = "M4A1 Supressed"
else
M4A1.Value = "Suprresed"
Button.Text = "M4A1"
end
end)

--Firing to the server
PlayButton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Event:FireServer()
end)

--local script in the new place
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer

local GunData = TeleportService:GetLocalPlayerTeleportData()
if GunData then
  player.M4A1.Value = GunData.M4A1
player.M82.Value = GunData.M82
player.Vector.Value = GunData.Vector
end)

--Server Script In new place

local Player = game:GetService("Players")

Player.PlayerAdded:Connect(function(Player) 
local M4A1 = Instance.new("StringValue", Player)
M4A1.Name = "M4A1"

local M82 = Instance.new("StringValue", Player)
M82.Name = "M82"

local Vector = Instance.new("StringValue", Player)
Vector.Name = "Vector"
end)


As @Messeras has said this system may not be the best way.
This system could also work with datastore.

--Server
--Variables
local DataStoreService = game:GetService("DataStoreService")
local GunStore = DataStoreService:GetDataStore("SceneStore")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.Event
local Delete = ReplicatedStorage.Delete

--Making the values
game.Players.PlayerAdded:Connect(function(Player)
local GunDataFolder = Instance.new("Folder", Player)
GunDataFolder.Name = "GunDataFolder"
	local M4A1 = Instance.new("StringValue", GunDataFolder)
	M4A1.Name = "M4A1"

	local M82 = Instance.new("StringValue", GunDataFolder)
	M82.Name = "M82"

	local Vector = Instance.new("StringValue", GunDataFolder)
	Vector.Name = "Vector"

local GetData =  GunStore:GetAsync(Player.UserId)

if GetData ~= nil then
	M4A1.Value = GetData[1]
		M82.Value = GetData[2]
		Vector.Value = GetData[3]
else
		M4A1.Value = ""
		M82.Value = ""
		Vector.Value = ""
end
end)


--Saving the data 
Event.OnServerEvent:Connect(function(Player)
	local SaveData =  {}
	for _,Child in pairs(Player.GunDataFolder:GetChildren())do
		table.insert(SaveData,Child.Value)
	end
	GunStore:SetAsync(Player.UserId, SaveData)
end)

--Deleting it forever until its set again
Delete.OnServerEvent:Connect(function(Player)
	GunStore:RemoveAsync(Player.UserID)
end)

I hope this helps, tell me if anything is wrong.
Also my bad I forgot to mention that the datastore will only work in these situations.

  1. The other place is under the same game
  2. You make a private Server

The scripts that say “In the new place” can be placed in the same place as long as you use private servers. If not then put it in the other place.

If you are teleporting to another place, make sure to make the events in that place aswell.

1 Like