#Its supposed to increase strength value when clicked
58 messages · Page 1 of 1 (latest)
my messges getting deleted
You might not have permission to send images. Open Discord on a web-browser and send the code that way
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local ProfileStore = ProfileService.GetProfileStore("Production", Template)
local KICK_MESSAGE ="bro flew a little too close to the SIGMA"
local function CreateLeaderstats(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local strength = Instance.new("NumberValue", leaderstats)
strength.Name = "Strength"
strength.Value = profile.Data.Strength
local gems = Instance.new("NumberValue", leaderstats)
gems.Name = "Gems"
gems.Value = profile.Data.Gems
end
local function LoadProfile(player: player)
local profile = ProfileStore:LoadProfileAsync("player_"..player.UserId)
if not profile then
player:Kick("")
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
player:Kick(KICK_MESSAGE)
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
CreateLeaderstats(player)
else
profile:Release()
end
end
for _, player in Players:GetPlayers() do
task.spawn(LoadProfile, player)
end
Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(player)
local profile = Manager.Profiles[player]
if profile then
profile:Release()
end
end)
First one
Manager script local Manager = {}
Manager.Profiles = {}
function Manager.AdjustStrength(player: Player, amount: number)
local profile = Manager.Profiles[player]
if not profile then return end
profile.Data.Strength += amount
player.leaderstats.Strength.Value = profile.Data.Strength
end
return Manager
local Template = {
Strength = 0,
Gems = 0,
}
return Template
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local Remotes = ReplicatedStorage.Remotes
local PlayerData = require(ServerScriptService.PlayerData.Manager)
local function Strength(player: Player)
PlayerData.AdjustStrength(player, 1)
end
Remotes.Strength.OnServerEvent:Connect(Strength)
** You are now Level 1! **
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Remotes
local StrengthRemote = Remotes.Strength
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
print("InputBegan event fired.")
if input.UserInputType == Enum.UserInputType.MouseButton1
or input.UserInputType == Enum.UserInputType.Touch
or input.KeyCode == Enum.KeyCode.ButtonR2 then
Remotes.Strength:FireServer()
print("Hello")
end
end)
Should i restart entirely on it?
How much have you debugged?
what do you mean
There arent anymore errors in the console but it still doesnt work
Yes, scripts can contains faults that don't raise errors
Do you know how to use the debugger?
No
It's a valuable skill. I recommend learning it: https://create.roblox.com/docs/studio/debugging
Does your script eventually work, or does it stay static?
It's activated by setting a breakpoint and running your code
Review the article I sent
where do i set a breakpoint
so i added a breakpoint between userinput service and local strengthRemote
it says rendering is paused for debugging
Yes, you can now step into, over, and out of functions. Hover over variables to see the value they hold
Stepping over iterates to the next instruction
Stepping into moves the debugger into a function so you can evaluate the function by stepping over it
Stepping out of lets you get out of that function without having to step over it completely
You'll probably want to start with how your server-sided logic handles the incoming request to change the player's strength
Do you mean the adjust strength?
and what if the arrow is inside of the breakpoint
and do i need print statements?
** You are now Level 2! **
Not with the debugger
Just step into and over, check values, notice conditions not passing
"Hover over variables to see the value they hold"
Oh i understand now
OK so i used the debugger tool and it says "FireServer can only be called from the client"
That's not coming from your scripts. And again, don't look to the output for information
it said exception hit when i hovered
#759524964977737808, screen share
Im gonna join on mobile
how do ishare sceen
It says you cant stream