I'm just trying to make an exe horror game, and i know i got alot of fe stuff to make and i really need help on this. I could learn from questions you put down, maybe i can learn from it.
I hope you can help me out a lil' and i don't want to act like an idiot here.
--LocalScript
script.Parent.CD.MouseClick:Connect(function(player) game.ReplicatedStorage.GiveRegularKey:FireServer() end)
--ServerScript
local client = game.Players.LocalPlayer game.ReplicatedStorage.GiveRegularKey.OnServerEvent:Connect(function() game.ReplicatedStorage.key:Clone().Parent = client.Backpack end)
Although I do not specialize in client-server communications as I stated in my comment, I will do my best to provide a solution.
LOCALSCRIPT:
script.Parent.CD.MouseClick:Connect(function(player) game.ReplicatedStorage.GiveRegularKey:FireServer() end)
SERVERSCRIPT:
game.ReplicatedStorage.GiveRegularKey.OnServerEvent:Connect(function(client) game.ReplicatedStorage.key:Clone().Parent = client.Backpack end)
I haven't tested it, but by reference from: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events#Client_to_Server
It should by theory work.
Edit (HaveASip recommended it): There was nothing wrong with the local script BUT there was a problem with the server script. As I did mention in my comment:
local client = game.Players.LocalPlayer
would never work in a server script, it only works in local scripts.
And as you saw here:
game.ReplicatedStorage.GiveRegularKey.OnServerEvent:Connect(function(client)
The 'client' in the function thing, the parameters is the player argument that all Client-To-Server provide. You'll always need to provide a player argument when adding parameters to an event.