My code not work [HELP!]

Client script :

local button = script.Parent
local queue = script.Parent.Parent.Parent.Parent.queue.queue
local createroom = game.ReplicatedStorage.createroom
local player = game:GetService("Players").LocalPlayer
local cards = button.Parent.setting.Cards.Cards
local RoomID = button.Parent.Parent.Parent.queue.queue.RoomID

button.MouseButton1Click:Connect(function()
	queue.Position = UDim2.new(-1, 0, 0.178, 0)
	queue.Parent.Visible = true
	queue.Visible = true
	button.Parent:TweenPosition(UDim2.new(-1, 0, 0.184, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.3)
	queue:TweenPosition(UDim2.new(0.126, 0, 0.178, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.3)
	wait(0.3)
	button.Parent.Visible = false
	button.Position = UDim2.new(0.025, 0, 0.184, 0)
	button.Parent.Parent.Visible = false
	local setting = {
		cards.Value,
	}
	local response = createroom:InvokeServer(player, 1, setting)
	print(player, 1, setting) --Output = Mek24048 1 {[1] = 10}
	RoomID.Value = response[1]
end)

CLIENT OUTPUT :

Mek24048 1  ▼  {
                    [1] = 10
                 }  -  Client - LocalScript:22

Server script :

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createroom = ReplicatedStorage.createroom
local ServerStorage = game:GetService("ServerStorage")

createroom.OnServerInvoke = function(player, roomType, setting)
	print(player, roomType, setting) --Output should be Mek24048 1 {[1] = 10} but it Mek24048 Mek24048 1
	local RoomID
	local existingRooms = ServerStorage.room:GetChildren()

	repeat
		RoomID = math.random(1000, 9999)
	until not RoomIDExists(RoomID, existingRooms)

	--<ROOM>--
	local newRoom = Instance.new("Folder", ServerStorage.room)
	newRoom.Name = RoomID
	local configuration = Instance.new("Configuration", newRoom)
	if roomType == 1 then
		local cards = Instance.new("IntValue", configuration)
		cards.Value = setting[1]
	end
	local Leader = Instance.new("IntValue", newRoom)
	Leader.Name = "leader"
	Leader.Value = player.UserId
	--<ROOM>--

	local responseData = {
		RoomID,
	}

	return responseData
end

function RoomIDExists(roomID, existingRooms)
	for _, room in ipairs(existingRooms) do
		if room.Name == tostring(roomID) then
			return true
		end
	end
	return false
end

SERVER OUTPUT :

Mek24048 Mek24048 1  -  Server - roomCreator:6

Anyone know why???

1 Like

You gave us exactly zero explanation of what you want to achieve. Next time when you make a post, please answer the questions it provides.

You do have an error that I recognize though. You’re sending player in :InvokeServer, even though the server already provides the player.

Client Code:

local player = game:GetService("Players").LocalPlayer
local createroom = game.ReplicatedStorage.createroom

local button = script.Parent
local queue = button.Parent.Parent.Parent.queue.queue
local cards = button.Parent.setting.Cards.Cards
local RoomID = queue.RoomID

button.MouseButton1Click:Connect(function()
	queue.Position = UDim2.fromScale(-1, 0.178)
	queue.Parent.Visible = true
	queue.Visible = true

	button.Parent:TweenPosition(UDim2.fromScale(-1, 0.184), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.3)
	queue:TweenPosition(UDim2.fromScale(0.126, 0.178), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.3)

	task.wait(0.3)
	button.Parent.Visible = false
	button.Position = UDim2.fromScale(0.025, 0.184)
	button.Parent.Parent.Visible = false

	local setting = {
		cards.Value,
	}

	local response = createroom:InvokeServer(1, setting)
	print(player, 1, setting) --Output = Mek24048 1 {[1] = 10}
	RoomID.Value = response[1]
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.