What do you want to achieve? i want to make a soccer ball locally get kicked on the client side and not the server side
What is the issue? i have a script that sees when the ball is touched and it checks if its a character and then i put it into a table to tell a other script the object in workspace so it does the rest of the stuff and makes it hit locally but instead it says Player.Exotic_stuffing so im guessing its not getting the player in workspace but it is getting player in workspace
What solutions have you tried so far? i edited the script for over 3 hours and nothing worked, i edited differnet stuff and it still doesnt work, and im bummed out of it.
local script (in startercharcaterscripts)
local Services = {
Players = game:GetService("Players"),
Debris = game:GetService("Debris"),
rep = game:GetService("ReplicatedStorage")
}
local Settings = {
Kick_Cooldown = 1,
Kick_Force = 35
}
local Ball = game.Workspace.SoccerBall
local KickSound = Ball:WaitForChild("Kick")
local IgnoreTable = {}
Ball.Touched:Connect(function(Part)
local Character = Part.Parent
if not Character then
return
end
local stuff = {
thing = Character
}
game.ReplicatedStorage.RemoteEvents.a:FireServer(stuff)
end)
main script (inside ball)
game.ReplicatedStorage.RemoteEvents.a.OnServerEvent:Connect(function(stuff)
local Ball = script.Parent
local Services = {
Players = game:GetService("Players"),
Debris = game:GetService("Debris")
}
local Settings = {
Kick_Cooldown = 1,
Kick_Force = 35
}
local Ball = script.Parent
local KickSound = Ball:WaitForChild("Kick")
local IgnoreTable = {}
local Character = stuff
local Player = Services.Players:GetPlayerFromCharacter(Character)
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Root = Character:FindFirstChild("HumanoidRootPart")
if not Player or not Humanoid or Humanoid.Health <= 0 or not Root or table.find(IgnoreTable, Player) then
return
end
local Direction = CFrame.lookAt(Root.HumanoidRootPart.Position, Ball.Position).LookVector
if Direction.Magnitude < 0.001 then
local Velocity = Instance.new("BodyVelocity")
Velocity.Parent = Ball
Velocity.MaxForce = Vector3.new(1, 1, 1) * math.huge
Velocity.Velocity = (Direction.Unit * Settings.Kick_Force) + Vector3.new(0, Settings.Kick_Force /1.05, 0)
Services.Debris:AddItem(Velocity, 0.2)
KickSound:Play()
end
end)
the player who fired is always the first variable when firing the server so you should use
game.ReplicatedStorage.RemoteEvents.a.OnServerEvent:Connect(function(Player, stuff) -- this is not the player who kicked but the player who fired the remote
from what i see you are going to have alot of clients firing the remote if they are all watching touched event on a server created soccer ball
game.ReplicatedStorage.RemoteEvents.a.OnServerEvent:Connect(function(Player, stuff)
local Ball = script.Parent
local Services = {
Players = game:GetService("Players"),
Debris = game:GetService("Debris")
}
local Settings = {
Kick_Cooldown = 1,
Kick_Force = 35
}
local Ball = script.Parent
local KickSound = Ball:WaitForChild("Kick")
local IgnoreTable = {}
local Character = stuff[1]
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Root = Character:FindFirstChild("HumanoidRootPart")
if not Humanoid or Humanoid.Health <= 0 or not Root or table.find(IgnoreTable, Player) then
return
end
local Direction = CFrame.lookAt(Root.Position, Ball.Position).LookVector
if Direction.Magnitude < 0.001 then
local Velocity = Instance.new("BodyVelocity")
Velocity.Parent = Ball
Velocity.MaxForce = Vector3.new(1, 1, 1) * math.huge
Velocity.Velocity = (Direction.Unit * Settings.Kick_Force) + Vector3.new(0, Settings.Kick_Force /1.05, 0)
Services.Debris:AddItem(Velocity, 0.2)
KickSound:Play()
end
end)
what you can do is do the connection to the ball server side when touched then get direction or locations to move it to then fire remote to the clients to move or do what you want to the ball this is also used to show bullets, snowballs, and other objects that move without server running the physics. but in your case its probably fine for the ball to be run by the server just make sure to set networkownership to the server else the closest client will pickup owner and cause the ball to twitch or lag as it moves