local active = 1
local player = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
if game.Players.LocalPlayer:FindFirstChild("Functional").Crates.Value > 0 and active == 1 then
active = 0
local a = require(player.PlayerGui.Modules.case):create()
workspace.Openings.RemoteEvent:FireServer(a)
wait(3)
active = 1
end
end)
a when printed is a string
Server side
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player,a)
print(a)
if player:FindFirstChild("Functional").Crates.Value > 0 then
player:FindFirstChild("Functional").Crates.Value = player:FindFirstChild("Functional").Crates.Value - 1
if a == "1 Wins" then
player:FindFirstChild("leaderstats").Wins.Value = player:FindFirstChild("leaderstats").Wins.Value + 1
elseif a == "2 Wins" then
player:FindFirstChild("leaderstats").Wins.Value = player:FindFirstChild("leaderstats").Wins.Value + 2
elseif a == "3 Wins" then
player:FindFirstChild("leaderstats").Wins.Value = player:FindFirstChild("leaderstats").Wins.Value + 3
else
if player.skins[a].Value == true then
player:FindFirstChild("leaderstats").Wins.Value = player:FindFirstChild("leaderstats").Wins.Value + 1
else
player.skins[a].Value = true
print("Attempt")
end
end
end
end)
when a is printed here for some reason it takes the string as a nil.
local active = true
local player = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
local crate = player:FindFirstChild("Functional").Crates.Value
if crate > 0 and active then
active = false
local a = require(player.PlayerGui.Modules.case):create()
--Server can't access to PlayerScript. Same manner to PlayerGUI?
workspace.Openings.RemoteEvent:FireServer(a,crate)
wait(3)
active = true
end
end)
Server side
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player,a,crate)
local ls = player:FindFirstChild("leaderstats").Wins.Value
print(a)
if crate > 0 then
player:FindFirstChild("Functional").Crates.Value = crate - 1
if a == "1 Wins" then
player:FindFirstChild("leaderstats").Wins.Value = ls + 1
elseif a == "2 Wins" then
player:FindFirstChild("leaderstats").Wins.Value = ls + 2
elseif a == "3 Wins" then
player:FindFirstChild("leaderstats").Wins.Value = ls + 3
else
if player.skins[a].Value == true then
player:FindFirstChild("leaderstats").Wins.Value = ls + 1
else
player.skins[a].Value = true
print("Attempt")
end
end
end
end)
local active = true
local player = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
local crate = player:FindFirstChild("Functional").Crates.Value
if crate > 0 and active then
active = false
local a = require(player.PlayerGui.Modules.case):create()
workspace.Openings.RemoteEvent:FireServer(tostring(a),crate)
wait(3)
active = true
end
end)
What’s in skins table that uses “a”, especially key side?
You’re sending a Require (Functions) To The Server, This for some reason can not be made.
It is also correct because a function that is requested by the client must remain client and not server
Server can not execute a function that should be executed by the client.
This also applies to the Server - Client
Instead Save the Value that the function return in an External Variable (On Local script) and then send it
Then the create() method is returning an ‘Instance’ not a string value as you erroneously stated. Roblox objects instanced by the client do not replicate and thus from the server’s perspective, appear as ‘nil’.