Ok, so... I'm trying to make a system to make that when the player has triggered a prompt, it will add some points to the player and show up in the leaderstats, but... for some reason doesn't work... please help me... I would thank the person who help me with this stuff.
The prompt local script:
local Players = game:GetService("Players") local player = Players.LocalPlayer local prompt = script.Parent local replicatedStorage = game:GetService("ReplicatedStorage") local remotesEvents = replicatedStorage:WaitForChild("RemotesEvents") local addDevPointsEvent = remotesEvents:WaitForChild("AddDevPoints") prompt.Triggered:Connect(function() addDevPointsEvent:FireServer(player) end)
And the main server script:
local replicatedStorage = game:GetService("ReplicatedStorage") local remotesEvents = replicatedStorage:WaitForChild("RemotesEvents") local addDevPointsEvent = remotesEvents:WaitForChild("AddDevPoints") local function PlayerSetup(player) local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats" local devPoints = Instance.new("IntValue", leaderstats) devPoints.Name = "DevPoints" devPoints.Value = 0 local funds = Instance.new("IntValue", leaderstats) funds.Name = "Funds" funds.Value = 0 end game.Players.PlayerAdded:Connect(PlayerSetup) addDevPointsEvent.OnServerEvent:Connect(function(player) player.leaderstats.DevPoints.Value = player.leaderstats.DevPoints.Value + 2 end)
Not sure what you're trying to do 100% but, this is something similar. You can modify this to fit your needs.
game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local devPoints = Instance.new("IntValue") devPoints.Name = "DevPoints" devPoints.Value = 0 devPoints.Parent = leaderstats local funds = Instance.new("IntValue") funds.Name = "Funds" funds.Value = 0 funds.Parent = leaderstats end) script.Parent.ProximityPrompt.Triggered:Connect(function(plr) plr:WaitForChild("leaderstats").DevPoints.Value += 2 end)
This is how I have it set up in workspace: https://gyazo.com/705f7421946e9b44acdaf09833e5c840
You can modify how long it takes to activate the prompt in the ProximityPrompt properties.