No worries, I'll help you out. I'll write a basic template for what you need to do:
Create a "Remote Event" instance and drop it inside of the "ReplicatedStorage".
Name it whatever you want.
Create a "Script" instance and drop it inside of the "ServerScriptService".
Name the script whatever you want.
Put a "Local Script" inside of the desired part in the "Workspace".
Name the local script whatever you want.
local _RS = game:GetService("ReplicatedStorage");
local event = _RS:WaitForChild("Event Name Here")
local part = script.Parent;
local xpToGive = 5;
local delay = 5;
local debounce = false;
part.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid");
if not humanoid then
humanoid = hit.Parent.Parent:FindFirstChild("Humanoid");
end
if humanoid then
event:FireServer(xpToGive);
end
end)
Above is the local script
This is the server script |
V
local _RS = game:GetService("ReplicatedStorage");
local _P = game:GetService("Players");
local event = _RS:WaitForChild("Event Name Here")
local inew = Instance.new;
event.OnServerEvent:connect(function(player, bonusXp)
local data = player:FindFirstChild("Data");
if data then
local exp = data:FindFirstChild("Exp");
if exp then
exp.Value = exp.Value + bonusXp;
end
end
end)
_P.PlayerAdded:connect(function(player)
local data = inew("Folder", player);
data.Name = "Data";
local level = inew("IntValue", data);
level.Name = "Level";
level.Value = 1;
local exp = inew("IntValue", data);
exp.Name = "Exp";
level.Changed:connect(function()
if exp.Value >= level.Value * 10 then
exp.Value = 0;
level.Value = level.Value + 1;
end
end)
end)
1 comment
Hopefully my answer semi-explains what you're looking for. Most of it is up to you, such as how the part needs to fire the event and such. It doesn't NEED to be a touched event. In the same case, you don't have to use levels and experience points and what not