Um... my script doesn't work. (duh) Anyways I am making a script so when an object is touched it adds a value that is inside the player's backpack. The script that receives that remote event is in character scripts. The remote event is in repStorage, and the serverScript is inside the object being touched. Her is the code for the server script inside object~~~~~~~~~~~~~~~~~ --Declare --GameServices local plr = game:GetService("Players").LocalPlayer local Workspace = game:GetService("Workspace") local repSto = game:GetService("ReplicatedStorage")
--Items local fooPic = script.Parent local AddValueEvent = repSto:WaitForChild("FoodPickupEvent")
--Process local function FireServerWhenTouched (hit, plr) if hit.Parent:FindFirstChild("Humanoid") then fooPic:Destroy() AddValueEvent:FireClient(plr) end end --Conect fooPic.Touched:Connect(FireServerWhenTouched)
and code inside player character ~~~~~~~~~~~~~~~~~ --Declar --GameServices local player = game:GetService("Players").LocalPlayer local pgui = player:WaitForChild("PlayerGui") local repStore = game:GetService("ReplicatedStorage") --RemoteEvent local AddValueEvent = repStore:WaitForChild("FoodPickupEvent") --PLayerGui local sg = pgui:WaitForChild("ScreenGui") local is = sg:WaitForChild("InStats") local foodAmm = is:WaitForChild("FoodAmm") local bp = player:WaitForChild("Backpack") local isf = bp:WaitForChild("InvStats") local accAmm = isf:WaitForChild("FoodAmm") --Process local function ChangeMessageWhenFired() accAmm.Value = (accAmm.Value + 1) foodAmm.Text = accAmm.Value end --Connect AddValueEvent.OnClientEvent:Connect(ChangeMessageWhenFired)