LocalScript:
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
workspace.RFpurchase:InvokeServer(lplayer, nearShop)
end
end)
repeat wait(.5) until lplayer.PlayerGui.Hud.Overlay
local overlay = lplayer.PlayerGui.Hud.Overlay
while wait(.1) and lplayer.Character.Humanoid.Health > 0 do
print(nearShop) -- ''HealthCrateShop'' or ''false'' depending on whether the If statement below passed
for i, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild'Shop' then
local distance = (v.ShopPart.Position - lplayer.Character.Torso.Position).magnitude
if distance < 10 then
nearShop = v
overlay.Visible = true
overlay.Text = v.OverlayText.Value
else
overlay.Visible = false
nearShop = false
end
end
end
end
ServerScript: (inside the shop part)
bought = false
price = 150
function workspace.RFpurchase.OnServerInvoke(lplayer, nearShop)
print(nearShop) -- ''Player1'' regardless of what was printed in the localscript
if lplayer and lplayer.Character:FindFirstChild('Humanoid') and nearShop == script.Parent then
if lplayer.Character.Humanoid.coins.Value >= price then
lplayer.Character.Humanoid.coins.Value = lplayer.Character.Humanoid.coins.Value - price
if not bought then
bought = true
for i=1, 7 do
local pickup = game.ReplicatedStorage.pickup:Clone()
pickup.BillboardGui.ImageLabel.ImageColor3 = Color3.new(0, 0, 1) -- hp
pickup.Parent = workspace
pickup.Position = script.Parent.lite.Position
pickup.Velocity = Vector3.new(math.random(-25, 25), 25, math.random(-25, 25))
pickup:BreakJoints()
end
script.Parent.lite:Destroy()
end
end
end
end
This is probably something to do with me getting remotefunction arguments mixed up, but I don't know what I did wrong, so i'd like some help.

1 comment
I hope that made sense to you!