So I'm making a data system that creates Instances based off data given to the server after a player touches a certain part. For example there is a blue part in workspace that has an ID stored in a Int value as a child, when the player touches the blue part it sends the ID to the server after which the server creates a new instance based off of the information stored in the ID. (I have all of the other components of the system working other then getting the data from A to B)

I have a RemoteEvent in ReplicatedStorage named onTouch that is supposed to transfer it but won't.

Here is the code that isn't working. Client:

local onTouchEvent = game.ReplicatedStorage.onTouch
local assetID = script.Parent:FindFirstChild("DataID").Value

function onTouched(part)
	local h = part.Parent:FindFirstChild("Humanoid")
	if (h ~= nil) then
		onTouchEvent:FireServer(assetID) --Supposedly sends the ID to the Server when fired
	end
end

Server:

local onTouchEvent = game.ReplicatedStorage.onTouch

function recievedDataID(assetID)
	print(assetID)
end

onTouchEvent.OnServerEvent:Connect(recievedDataID)

I have the function in the server made to just print the ID to test it out, (I have the instance making function already made and working with already existing values.)

I'm basically trying to make a data system that creates itself based off the players gaming rather then just having all the stats already made and implemented into each player when they join. If anyone could help me with this part I'd be much appreciative! Thank you!

4 comments

0

Try putting two variables, one for the Client/Player and one for the AssetId. So it becomes recievedAssetID(Player, assetID).

0

Is the "AssetID" instance created on client side? if so, the problem would be the server side not seeing the client sided "AssetID".

0

I tried that and it didn't seem to work, maybe I'm missing something? I'm quite new to Remote Events/Functions. Also the AssetID is sent to the server and the server then creates the instance based off of the Asset ID

0

Is it possible to change the Remote Event to a bool value with an intvalue as child so when player touches part the bool becomes true and the ID is posted into the intvalue which would then be picked up by the server?