So i want a cube of light to be placed wherever the player has his/her mouse when they press R. I'm not sure what the issue is with the code I made.
Local Script:
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local RepStorage = game:GetService("ReplicatedStorage")
local DeletePart = RepStorage.DeletePart
local UIS = game:GetService("UserInputService")
local part = game.Workspace.deletepart
UIS.InputBegan:Connect(function(input)
local Hitposition = Mouse.Hit
if input.KeyCode == Enum.KeyCode.R then
print("R Pressed")
if Hitposition == nil then
DeletePart:FireServer(Hitposition)
end
end
end)
Server Script:
local RepStorage = game:GetService("ReplicatedStorage")
local DeletePart = RepStorage.DeletePart
local Cube = game.ServerStorage.LightCube:Clone()
local Cooldown = {}
DeletePart.OnServerEvent:Connect(function(Player, Position)
if Cooldown[Player.name] then return warn(Player.Name.." is on cooldown")end
Cooldown[Player.Name] = os.time
Cube.Name = string.format("%s part", tostring (Player.name))
Cube.Parent = game.Workspace
Cube.CFrame = Position
delay(2,function() -- 2 = cooldown time
Cooldown[Player.Name] = nil
end)
end)

5 comments
Thanks guys for all the help!
How do you know there even is an issue if you don't know what the issue is?
We can't help you if you don't give us more than "issue"
Could you be a bit more descriptive? What is not happening the way you want it to?
What exactly is the problem? Is the cube not appearing? If so, I think I know the problem; and that is because you used mouse.Hit and not mouse.Hit.Position.