Are you managing more than 1 module in 1 script on the server? If so maybe one of your modules could be looping causing a yield for the other modules to be required. You could wrap a coroutine around the loop to allow other modules to run.
no i am not managing over 1 module in 1 script.
Your scripts shown in your original post doesnât seem to have any problems with it, have you tried changing the value of your coins on the server yet?
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name ="leaderstats"
stats.Parent = player
local OwnedItems = Instance.new("Folder")
OwnedItems.Parent = game.ServerStorage.OwnedItems
OwnedItems.Name = player.Name
local Strength = Instance.new("NumberValue")
Strength.Name ="Strength"
Strength.Parent = stats
local Equipped = Instance.new("StringValue")
Equipped.Parent = player
Equipped.Name = "Equipped"
local Coins = Instance.new("NumberValue")
Coins.Name ="Coins"
Coins.Parent = stats
Coins.Value = 99999999999999999999999999999999999999
local gems = Instance.new("NumberValue", stats)
gems.Name = "Gems"
local storage = Instance.new("NumberValue")
storage.Value = 10
storage.Name = "Storage"
storage.Parent = player
local Class = Instance.new("StringValue")
Class.Name = "Class"
Class.Parent = stats
local Ownedtools = Instance.new("Folder")
Ownedtools.Parent = player
Ownedtools.Name = "Ownedtools"
end)
this is my leaderstats. Hope this helps
And this script running on the server, correct?
yes, it running the server.
This text is blurred
Do this
shop.canbuy.MouseButton1Click:Connect(function()
print(selectedtemp)
if selectedtemp ~= nil then
local result = game.ReplicatedStorage.Remotes.buytool:InvokeServer(selectedtemp.Name)
print(result)
end
print("Working")
end)
Then look at your output
it prints the name of the tool, but still doesnt work.
That is not safe. Exploiters can abuse this.
So it prints selectedtemp and not result and not âworkingâ
Iâm thinking. This thing is waiting forever
Check if thereâs actually a thing named âToolsâ under âSharedâ under rep store
Is the server sided script a module script?
yes, it is a module script.
AHHHHH LIMIT
Yes it is inside replicated storage and the folder shared.
And where is the module script located?
Try this
game.ReplicatedStorage.Remotes.buytool.OnServerInvoke = function(player,toolName)
return remotecon.buy(player,toolName)
end
Module scripts are cannot use events, they are for storing and sharing functions, values, and etc. What you need to do is to create a script that will actually process the function, modules can only store them. You could do something like this:
local remotecon = require( --Add the appropriate reference here)
local buytool = --Add the appropriate reference here
buytool.OnServerInvoke = function(player, toolName)
remotecon.buy(player,toolName)
end
it is located in Server script service
It works, but when i buy it again , my currency value is decreasing. I have written the code for that which is :
elseif player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value ~= toolName then
print("h")
for i,v in pairs(player.Backpack:GetChildren()) do
print("A")
if v:IsA("Tool") then
v:Destroy()
print("m")
end
end
local gear = tool:Clone()
print("f")
gear.Parent = player.Backpack
print("c")
return "Equipped"
elseif player.Ownedtools:FindFirstChild(toolName) and player.Equipped.Value == toolName then
print("b")
for i,v in pairs(player.Backpack:GetChildren()) do
print("raid")
if v:IsA("Tool") then
v:Destroy()
print("shadow")
end
end
local gear = tool:Clone()
print("legends")
gear.Parent = player.Backpack
return "Equipped"
end
Isnât the currency decreasing when you buy it what is supposed to happen?