Hello,
I’m trying to test when someone clicks. But, how am I going to do this during a normal script?
Thank you,
for reading.
What do you mean someone clicks in a server script? Do you meant that when you’re clocking teh script instance in the explorer tab, you want to detect that?
I’m trying to make a client sided projectile to have 0 delay.
That is something that is not possible. Handle your input in LocalScripts, otherwise players will be subject to input lag.
Okay how should I stop the delay from my projectile then?
So this gets a little more advanced now, but a lot of games just cheat. If a player fires their gun, create the bullet, animation, and sounds locally for that player. Then send the RemoteEvent and create the bullet and firing effects for everyone else. The delay is unavoidable in networking no matter how you do it, but this little cheat makes the player’s gun feel like it responds instantly. Nobody else will notice of course since they aren’t the one firing your gun. This method typically ends up being the best option for handling the delay
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
local mousePos1 = mouse.Hit --cframe value of mouse position
local mousePos2 = mouse.Hit.p --vector3 value of mouse position
--you can send this data to the server with remote events
end)
Local script but it is possible to send the information to a server script through the use of a “RemoteEvent” instance.
there isn’t a need for this in a local script
local scripts run when the player joins
local player = players.LocalPlayer
is good enough
I know I just have those top 2 lines copied & pasted for general use.