I am having trouble trying to figure out how to change leaderstats in a separate script. I want it to work so that when a player is touching the part it will give them 1 EXP every second, and this is in a local script. Here is the script
local Player = game.Players.LocalPlayer
local LeaderStats = Player:WaitForChild("leaderstats")
local Level = LeaderStats:WaitForChild("Level")
local EXP = Player:WaitForChild("EXP")
script.Parent.Touched:connect(function(touch)
if touch.Parent:findFirstChild("Humanoid") then
touching = true
while touching do
EXP.Value = EXP.Value + 1
wait(1)
end
end
end)
script.Parent.TouchEnded:connect(function(untouch)
if untouch.Parent:findFirstChild("Humanoid") then
touching = false
end
end)
Normal Script
local t = false script.Parent.Touched:Connect(function(touch) if touch.Parent:FindFirstChild("Humanoid") and t == false then t = true local plr = game.Players:FindFirstChild(touch.Parent.Parent.Name) plr:FindFirstChild("leaderstats").EXP.Value = EXP.Value + 1 end end) script.Parent.TouchEnded:Connect(function(untouch) if untouch.Parent:FindFirstChild("Humanoid") and t == true then t = false end end)