Localscript
local button = script.Parent
local debounce = false
local regenEvent = game.ReplicatedStorage.Regen
local function onHit()
if debounce then
end
debounce = true
button.BackgroundColor3 = Color3.fromRGB(170, 255, 127)
regenEvent:FireServer()
button.BackgroundColor3 = Color3.fromRGB(170, 255, 0)
debounce = false
end
button.Activated:Connect(onHit)
Script
local regenEvent = game.ReplicatedStorage.Regen
regenEvent.OnServerEvent:Connect(function(player)
local clone = game.Workspace.CopyPasteChassis:Clone()
clone.Body.Anchored = false
local newPos = Vector3.new(0,5,0) + player.Character.PrimaryPart.Position
clone:SetPrimaryPartCFrame(CFrame.new(newPos)*CFrame.Angles(0,math.rad(player.Character.PrimaryPart.Orientation.Y),0))
end)
The localscript is inside of a button that fires it (or, at least, should fire it) when clicked by the user. The localscript fires the "Regen" event already in replicated storage when the game starts, and the server sided script that resides in workspace should be waiting for that event to be fired and use the CFrame of the character of the player that fired it, which is passed automatically, to adjust the CFrame of a cloned vehicle named CopyPasteChassis that I placed inside of some terrain in the workspace to be close to the player. It also adjust its angle, but that part isn't necessary.
It doesn't work at all. It used to spawn a new car at 0,0,0 but now it just does nothing. It throws no exceptions either so I have no idea how to fix it. Removing the part with CFrame doesn't change anything. It's likely the button isn't firing the event.

2 comments
change player.Character.PrimaryPart.Position to player.Character.HumanoidRootPart.Position, primary part is not a valid member of a character but we already know the primary part is the humanoidrootpart
Thanks but that doesn't solve the issue of nothing happening when I press the button