Also I want to know that if the IntValue should not be in the client side, where should I put them in, and how to copy them back to the client side to let players see their XP/ level ?
you can put them in a folder in a player called leaderstats, then it will show on the leaderboard tab
Oh I know that, but I want to know if it’s possible not letting other players seeing your XP while they are in the leaderboard?
then you can just set an attribute to the player using :SetAttribute(“NameOfAttribute”, value)
Ok thx! This also might help me for one of my ideas since I need to basically do the same thing as this.
If it works I’ll make it a solution
Hey @Pure_Bacn I found out that you can just make a Folder that named hidden and put it in the leaderstats folder, then everythng in that hidden folder is hidden and can’t be seen from public, but still it is in the leaderboard.
I think this can saved by the game, because it’s in the leaderstats, it just you can’t see it
In order to save it you need datastore.
heres a link to help you:
I know there’s an article that teach data storage, but now since I added the IntValue to the leaderboard, I wonder can I change through a script
yes you can you just have to do it via serverscript
OOOO thx I’ll try, also can you gimme an example script, like maybe an IntValue got changed within the server script? And also is there a way to change specific player IntValue in the script?
Well you can use an attribute so like:
game.Players.PlayerAdded:Connect(function(player)
player:SetAttribute("XP",0) --If attribute xp exists, overwrite it, if not create it with value of 0
end
I wonder is it possible to not use an attribute but have the same result as what I wanted?
- You need to pass the player your firing to remote to.
-
if game.replicatedstorage.xptrigger:FireClient()
would not work since it would return a nil value ( nothing ) because only remotefunctions and bindablefunctions return something.
I don’t know if this works since I haven’t tested it but give it a try
First, you want to add a ModuleScript in ServerScriptService called GetPlayer
Then type in this in the Module Script:
local module = {}
game.Players.PlayerAdded:Connect(function(player)
function module.GetPlayer()
return player
end
module.GetPlayer()
end)
return module
(Script inside of an enemy)
local GetPlayer = require(game:GetService("ServerScriptService").GetPlayer)
script.Parent.zombie.Died:Connect(function()
local player = module.GetPlayer()
print('It is dead!')
local CheckIfZombieDied = game.ReplicatedStorage.XPtrigger:FireClient(player)
if CheckIfZombieDied then
print('It fired!')
end
end)
(Inside of StarterPlayerScripts)
game.ReplicatedStorage.XPtrigger.OnClientEvent:Connect(function()
-- check if it received the firing event from the remote event
print('It receive!')
script.Parent.Parent.LevelsInfo.playerXP.Value += 15
return true
end)
Then use an intvalue (Instance.new(“IntValue”,player))
Oh ok, so that means of a just do a local player = game.Players.localPlayer
then add that player to the bracket inside of the FireClient()
Your quite of close, you can’t use LocalPlayer inside a serverscript.
To get the player who killed the npc/player use a creator tag.
local tag = humanoid:FindFirstChild('creator')
if tag and tag.Value then
remote:FireClient(tag.Value)
end