I want my remote event to send the player and a string to the server script.
In my server script, it is reading the accessory as a Player for some reason. It’s giving me this output when I try to print the accessory value: "Value is not a valid member of Player “Players.ballerawesomeg_dog” ".5
Local Script:
local gPlayers = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")
local serverStorage = game:GetService("ServerStorage")
local marketPlace = game:GetService("MarketplaceService")
-- ^ Services ^
local Player = gPlayers.LocalPlayer
local event1 = repStorage.LockerFolder.ChangeLocker
local accessory = serverStorage:WaitForChild("FastHelmet").CustomFastHelmet
script.Parent.MouseButton1Click:Connect(function()
if marketPlace:UserOwnsGamePassAsync(Player.UserId, 36177941) then
print("Player Owns")
event1:FireServer(Player, accessory)
else
print("Player Doesn't Own")
marketPlace:PromptGamePassPurchase(Player)
end
end)
Server Script:
local gPlayers = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")
local serverStorage = game:GetService("ServerStorage")
local marketPlace = game:GetService("MarketplaceService")
-- ^ Services ^
local event1 = repStorage.LockerFolder.ChangeLocker
event1.OnServerEvent:Connect(function(Player, accessory)
local char = Player.Character
local Hum = char.Humanoid
local accessoryLoaded = accessory:Clone()
print(accessory.Name)
Hum:AddAccessory(accessoryLoaded)
end)
I think this is right, although I just ran some tests and for some reason the script isn’t even registering the MouseButton1Click: (Didn’t print the “Pass Click”)
script.Parent.MouseButton1Click:Connect(function()
print("Pass Click")
if marketPlace:UserOwnsGamePassAsync(Player.UserId, 36177941) then
print("Player Owns")
event1:FireServer(accessory)
else
print("Player Doesn't Own")
marketPlace:PromptGamePassPurchase(Player)
end
end)
To my knowledge, I believe local scripts CANNOT access ServerStorage or ServerScriptService. You can put it in Replicated storage where both of it can access it.
This was part of the problem, but the other part was quite embarrassing, to say the least, turns out all the script I was typing was in the wrong ImageButton.
Also, I found another issue. You’re sending the player and the accessory. Why? Player is always automatically the first argument when you’re receiving on the server. You don’t need to send it from the client. However for the client, you must send the player to the client.