#How do i fix this stutter?

1 messages · Page 1 of 1 (latest)

frosty crest
forest cloudBOT
#

studio** You are now Level 3! **studio

frosty crest
#
local tool = script.Parent
local remoteEvent = tool:WaitForChild("RemoteEvent")
local meshTemp = game.ReplicatedStorage.Templates.GrenadeMesh


local THROW_POWER = 75
local UPWARD_FORCE = 50 

remoteEvent.OnServerEvent:Connect(function(plr)
    local char = plr.Character
    if not char or not char:FindFirstChild("HumanoidRootPart") then return end

    local root = char.HumanoidRootPart

    
    local clone = meshTemp:Clone()
    clone.Parent = workspace

    
    clone.CFrame = root.CFrame * CFrame.new(0, 0, -3)

    
    local launchVelocity = (root.CFrame.LookVector * THROW_POWER) + Vector3.new(0, UPWARD_FORCE, 0)

    
    clone.AssemblyLinearVelocity = launchVelocity
end)

(the server script)

local remoteEvent = script.Parent:WaitForChild("RemoteEvent")
local tool = script.Parent

tool.Activated:Connect(function()
    
    remoteEvent:FireServer()
end)

(local)

unkempt fox
#

try

#

uh

#

it has to do with network ownership

#

thats why the delay

forest cloudBOT
#

studio** You are now Level 15! **studio

frosty crest
unkempt fox
#

ok when u throw the grenade

#

you fire a remote right

frosty crest
unkempt fox
#

now

#

when you fire a remote

#

you make the grenade without waiting for the server

#

make the grenade on client and throw it right

#

then the server verifies it etc etc and send a remote to all the other clients

#

then they make a grenade on their own game

frosty crest
#

so first in local script you fire remote then make the throw in the same local

unkempt fox
#

yep

#

you assume the server will accept the grenade

#

otherwise you will get annoying delays

frosty crest
#

after you catch the event on server script you do the checks and send a remote to all clients

unkempt fox
#

yes

frosty crest
#

and you use onclient event on the local script?

unkempt fox
#

yeah

frosty crest
#

and make the grenade on onclient event

unkempt fox
#

but the client throwing it

#

doesnt do that

#

the client throwing it fires the remote and makes the grenade* in the same function

#

because if you wait for the server there will be a delay and itwont be smooth

frosty crest
#

i will send you the scripts after i try okay?

unkempt fox
#

ok

frosty crest
#
local tool = script.Parent
local remoteEvent = tool:WaitForChild("RemoteEvent")
local meshTemp = game.ReplicatedStorage.Templates.GrenadeMesh

local THROW_POWER = 75
local UPWARD_FORCE = 50 
local plr = game.Players.LocalPlayer
tool.Activated:Connect(function()

    remoteEvent:FireServer()
 remoteEvent.OnClientEvent:Connect(function()
        local char = plr.Character
        if not char or not char:FindFirstChild("HumanoidRootPart") then return end

        local root = char.HumanoidRootPart

        local clone = meshTemp:Clone()
        clone.Parent = workspace

        clone.CFrame = root.CFrame * CFrame.new(0, 0, -3)

    
        local launchVelocity = (root.CFrame.LookVector * THROW_POWER) + Vector3.new(0, UPWARD_FORCE, 0)

        clone.AssemblyLinearVelocity = launchVelocity
 end)
end)

(local)

local tool = script.Parent
local remoteEvent = tool:WaitForChild("RemoteEvent")
local meshTemp = game.ReplicatedStorage.Templates.GrenadeMesh


local THROW_POWER = 75
local UPWARD_FORCE = 50

remoteEvent.OnServerEvent:Connect(function(plr)


    remoteEvent:FireAllClients()
    

end)


(server script) i think i ddint do it right

#

@unkempt fox

unkempt fox
#

does the grenade go smoothly in ur client

#

on the server u need to send needed data to other clients

frosty crest
unkempt fox
#

because

#

ur connecting inside the activated function

#

ur connecting a new remote event every time u click

#

so it multiplies

frosty crest
#

so i should separate the remotes?

unkempt fox
#

put this outside activated

frosty crest
unkempt fox
#

because u need to send the needed grenade data to other clients

frosty crest
#

so i should put something is here?

#

what should i send to the clients?

#

ive got nothing to send

#

sorry for being intrusive @unkempt fox

#

but i need it to work

unkempt fox
#

its fine

#

u need to send where the grenade is being spawned at what force etc etc

frosty crest
#
local tool = script.Parent
local remoteEvent = tool:WaitForChild("RemoteEvent")
local meshTemp = game.ReplicatedStorage.Templates.GrenadeMesh


local THROW_POWER = 75
local UPWARD_FORCE = 50

remoteEvent.OnServerEvent:Connect(function(plr, spawnPos, throwPower, upwardForce)


    remoteEvent:FireAllClients(plr, spawnPos, throwPower, upwardForce)
    

end)


The server script

local tool = script.Parent
local remoteEvent = tool:WaitForChild("RemoteEvent")
local meshTemp = game.ReplicatedStorage.Templates.GrenadeMesh

local THROW_POWER = 75
local UPWARD_FORCE = 50 
local plr = game.Players.LocalPlayer
tool.Activated:Connect(function()

    remoteEvent:FireServer(plr.Character.HumanoidRootPart.Position, THROW_POWER, UPWARD_FORCE)

end)
 remoteEvent.OnClientEvent:Connect(function(plr, spawnPos, throwPower, upwardForce)
        if (plr == game.Players.LocalPlayer) then return end
        local char = plr.Character
        if not char or not char:FindFirstChild("HumanoidRootPart") then return end

        local root = char.HumanoidRootPart

        local clone = meshTemp:Clone()
        clone.Parent = workspace

        clone.CFrame = spawnPos.CFrame * CFrame.new(0, 0, -3)

    
        local launchVelocity = (spawnPos.CFrame.LookVector * throwPower) + Vector3.new(0, upwardForce, 0)

        clone.AssemblyLinearVelocity = launchVelocity
 end)

the local script.Honestly i doesnt even know what im doing and everything stopped working and i think i should just leave it with this stutter rather than trying to figure it out

#

@unkempt fox

unkempt fox
#

well u can do that

#

but i suggest learning about

#

how remotes work

#

and server client relation

frosty crest
unkempt fox
#

ye i want to help but im busy rn

frosty crest
#

okay

#

ive got it to work only on one client but still great progress i made

forest cloudBOT
#

studio** You are now Level 4! **studio