I have the server handling creating the part and delivering the damage while the client plays animations and sounds
Make sure you use tween for resizing the part or your lerp values are low
You could also do the damage on the client at the same time, just make sure to ignore signal from server.
I have a seperate script that creates a connecting brick between 2 points while the one point uses a body velocity to fire like a bullet
You should do all visualization on the client, so these issues do not present themselves. There will always be a delay because possible bad internet connection, so you have to account for that. You coudl instead send the command to the server, where the server sends the visualization commadn to all the clients.
im confused on how I would go about this
The same way you handle playing animations and sounds on the client
But then other people wont be able to see the skill right?
that’s the point here, you’ll be using the server to fire to all clients the data of the skill use, and visualize it per client
Could you by chance show me an example with a script that makes a part on the client and has the server fire the client, im not to good with understanding this server to client stuff
Server Script
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local function checkValidity(player)
-- put your code here which is responsible for checking if the player can actually use the ability and stuff
end
remoteEvent.OnServerEvent:Connect(function(player, abilityType)
if checkValidity(player) then
remoteEvent:FireAllClients(abilityType)
end
end)
Local Script
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local function triggerAbility(abilityType)
remoteEvent:FireServer(abilityType)
end)
remoteEvent.OnClientEvent:Connect(function(abilityType)
if abilityType == "Kame Hame Ha" then
-- do code like particles, parts and stuff
end
end)
-- if player does ability trigger, fire function
-- triggerAbility()
This is kind of pseudo code and doesn’t actually work. It’s more to give you a better understanding.
I appreciate it, thank you, ill look through it and try to understand it
I have one question, how would i check for validity to see if the player is already using a skill, this is the code i have so far after playing around with it
Server:
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local function checkValidity(player)
if player then
return true
end
end
remoteEvent.OnServerEvent:Connect(function(player, abilityType)
if checkValidity(player) then
remoteEvent:FireAllClients(abilityType, player)
end
end)
Client:
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local UserInputService = game:GetService("UserInputService")
local Debris = game:GetService("Debris")
local function triggerAbility(abilityType)
remoteEvent:FireServer(abilityType)
end
remoteEvent.OnClientEvent:Connect(function(abilityType, User)
local Character = User.Character
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChild("Humanoid")
if HumanoidRootPart and Humanoid then
if abilityType == "Kamehameha" then
HumanoidRootPart.Anchored = true
Humanoid.AutoRotate = false
local Part = Instance.new("Part", game.Workspace)
Part.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,0,-1)
Part.Anchored = true
Part.CanCollide = false
Part.Size = Vector3.new(1,1,1)
Part.Shape = Enum.PartType.Ball
Part.BrickColor = BrickColor.new("Electric blue")
Part.Material = Enum.Material.Neon
Debris:AddItem(Part,3)
wait(3)
Humanoid.AutoRotate = true
HumanoidRootPart.Anchored = false
end
end
end)
local function onInputBegan(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.ButtonX then
triggerAbility("Kamehameha")
end
end
UserInputService.InputBegan:Connect(onInputBegan)
You could for example add a cooldown table or find out how you give the ability to that person and check it that way . I’m not sure how your codebase looks like so I can’t give accurate advice.
a cooldown table like a table that runs off the server that adds and removes players as they use attacks?
yes, you are correct in your statement
So like this essentially?
Server:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Attacking_Players = {}
local function Check(player)
for _,v in pairs(Attacking_Players) do
if v == player.Name then
return false
end
end
table.insert(Attacking_Players,player.Name)
return true
end
Event.OnServerEvent:Connect(function(player, reason, name)
if reason == "Ability" then
if name == "Kamehameha" then
if Check(player) then
Event:FireAllClients(name, player)
end
end
end
if reason == "Remove Player" then
for i = 1, #Attacking_Players do
if Attacking_Players[i] == name then
table.remove(Attacking_Players, i)
end
end
end
end)
Client:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local UserInputService = game:GetService("UserInputService")
local Debris = game:GetService("Debris")
local function Ability(reason, name)
Event:FireServer(reason, name)
end
Event.OnClientEvent:Connect(function(name, player)
local Character = player.Character
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChild("Humanoid")
if HumanoidRootPart and Humanoid then
if name == "Kamehameha" then
HumanoidRootPart.Anchored = true
Humanoid.AutoRotate = false
local Part = Instance.new("Part", game.Workspace)
Part.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,0,-1)
Part.Anchored = true
Part.CanCollide = false
Part.Size = Vector3.new(1,1,1)
Part.Shape = Enum.PartType.Ball
Part.BrickColor = BrickColor.new("Electric blue")
Part.Material = Enum.Material.Neon
Debris:AddItem(Part,3)
wait(3)
Humanoid.AutoRotate = true
HumanoidRootPart.Anchored = false
Event:FireServer("Remove Player", player.Name)
end
end
end)
local function onInputBegan(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.ButtonX then
Ability("Ability", "Kamehameha")
end
end
UserInputService.InputBegan:Connect(onInputBegan)