Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to share data with remote events?

im trying to share this through remote event but its not allowing periods this is my top line, how could I share this?

LOCAL SIDE(ON CLICK):

script.Parent.MouseButton1Click:connect(function()
	local player = game.Players.LocalPlayer
	if player ~= nil then
	if workspace["Zednov's Tycoon Kit"].Tycoons:FindFirstChild(workspace.CurrentCamera.CameraSubject.Name).Owner.Value == nil then
		workspace["Zednov's Tycoon Kit"].Tycoons:FindFirstChild(workspace.CurrentCamera.CameraSubject.Name).Owner.Value = workspace:FindFirstChild(player.Name)
		game.ReplicatedStorage.ClaimTycoon:FireServer(player, workspace.CurrentCamera.CameraSubject.Name)
		game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
		game.Workspace.CurrentCamera.CameraType = "Custom"
		end
	end
end)


SERVER SIDE:

game.ReplicatedStorage.ClaimTycoon.OnServerEvent:connect(function(player, CameraSubject)
	if player ~= nil then
		local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
	if PlayerStats ~= nil then
		local ownstycoon = PlayerStats:FindFirstChild("OwnsTycoon")
	if ownstycoon ~= nil then
	ownstycoon.Value = workspace["Zednov's Tycoon Kit"].Tycoons:FindFirstChild(CameraSubject.Name)
		player.TeamColor =workspace["Zednov's Tycoon Kit"].Tycoons:FindFirstChild(CameraSubject.Name).TeamColor.Value
		player.PlayerGui.Menu.TycoonSelect.Visible = false
		player.Character:MoveTo(workspace["Zednov's Tycoon Kit"].Tycoons:FindFirstChild(CameraSubject.Name).Essentials.Spawn.Position + Vector3.new(0,2,0))
			end
		end
	end
end)

1 answer

✓ Accepted answer

You're looking for a RemoteEvent's FireServer() method. What you're doing right now is listening for OnServerEvent with invalid syntax.

game.ReplicatedStorage.ClaimTycoon:FireServer(workspace.CurrentCamera.CameraSubject.Name)

That's how you'd achieve what you're trying to do! Server-side you'd use the RemoteEvent's OnServerEvent event to receive data, like so:

game.ReplicatedStorage.ClaimTycoon.OnServerEvent:Connect(function(player, cameraSubjectName)
	print(cameraSubjectName)
end)

1 comment

0

Its saying the subject is player but it isnt its on the tycoon

This discussion is preserved as it was. New answers, comments, and votes are closed.