ServerEvent first argument is player so playerGettingReward argument won’t be needed.
Yes, true. I just put that in to make it clearer.
Why you’re making the event listener a variable and how do you get coins
variable in it?
I don’t understand what you mean.
The code should look like this
script.Parent.Touched:Connect(function(Touch)-- This is the default coin script
local plr = game.Players.LocalPlayer
if Touch.Name == “Tool” then
local coins = Instance.new('IntValue',plr)
coins.Name = Coins
script.Parent:Destroy()
coins.Value += 1
end
plr. PlayerGui.Shop.Frame.UpgradeButton.MouseButton1Click:Connect(function(ClickButton)
if ClickButton and Touch.Name == “Tool” then
local event = game.ReplicatedStorage:WaitForChild(“RemoteEvent”)
game.ReplicatedStorage.Stringevent.OnServerEvent:Connect(function(player,message)
if message == “GiveCoins” then
local coinns = plr.Coins
coinns.Value += 10
print(“Success!”)
wait(0.01)
script.Parent:Destroy()
end
end)
end
end)
end)
How did you put a script inside the IntValue???
What do you mean? I just put a script inside of the IntValue
Try the new updated code. This should be a LocalScript.
How do I put the IntValue inside of the player though?
Just put that code in the LocalScript where the old script was located. Where did i mention about any IntValues?
I used the script and now not even the 1 coin script works
There isn’t any error in the output either.
There should be an IntValue named Coins in the player. Check if there is. This should create automatically after that something was touched by a tool.
Where did you put that script? Also was it a LocalScript?
I put the script inside the part and yes it is a LocalScript
There is not an IntValue in the player
But did you touch the part by a tool before checking?
Yeah, I did do that but it did nothing.
I know what is the problem. I’ll reformat that tomorrow because rn I’m on mobile and it’s kinda hard to do it on it. The problem is that the OnServerEvent part should be in another normal script in ServerScriptService.
I changed the type of the script to a local script and it destroys the part but it doesn’t change the value inside of the player. There is no error or print in the output either.