How can i make press key and that will clone the part to workspace??
it should we client sided…
like if i press ‘p’ then the the building will clone to workspace…
How can i make press key and that will clone the part to workspace??
it should we client sided…
like if i press ‘p’ then the the building will clone to workspace…
Could you be more detailed so I can understand the question a bit more?
if i press ‘p’ on my keyboard then theres a building in ServerStorage…
After press key ‘p’ it will clone the part to workspace.
Okay. In starterplayer scripts, make a localscript.
Then write
local Mouse = Player:GetMouse()
local keybind = "p"
Mouse.KeyDown:Connect(function(key)
if key == keybind then
-- clone the part
end
ok thanks! ill try this out! thanks for helping…
This won’t work since the building is in ServerStorage, I also don’t recommend using Mouse since this has been supplanted by CAS/UIS.
To OP:
You can follow a method of using Context Action Service to bind the input, p, to a function that replicates the information to the server - firing a remote event that is received by the server and then clones the building into workspace accordingly.
thanks it works! but your code is missing somthing imma put this here…
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local keybind = "p"
Mouse.KeyDown:Connect(function(key)
if key == keybind then
print("hi")
end
end)
i can just use RemoteEvent… and i got it working…
Yes, that’s what my post had said.
The other point of my post is to steer you away from using Player:GetMouse
as opposed to CAS/UIS.
Here is an example code using UIS:
game:GetService("UserInputService").InputBegan:Connect(function(input,gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.P then
print("P Key Pressed")
end
end
end
end)
And an example code using CAS:
function pPressed(name,inputState)
if inputState == Enum.UserInputState.Begin then
print("P Key Pressed")
end
end
game:GetService("ContextActionService"):BindAction("spawnBuilding",pPressed,false,Enum.KeyCode.P)