local module = {}
local DebriService = game:GetService('Debris')
local TKPushData = {
DebounceTime = 3,
Debounce = {},
Victims = {},
}
function CheckDebounce(Character,Target)
local CanAttackVictim = true
local CanAttack = false
if not TKPushData['Debounce'][Character] then
TKPushData['Debounce'][Character] = {
Last = tick()+TKPushData['DebounceTime']
}
CanAttack = true
end
if TKPushData['Debounce'][Character] then
if tick() - TKPushData['Debounce'][Character]['Last'] >= TKPushData['DebounceTime'] then
CanAttack = true
end
end
if TKPushData[table.find(TKPushData['Victims'],Target)] then
CanAttackVictim = false
end
if CanAttack==true and CanAttackVictim==true then
return true
end
--Targets[table.find(Targets, Target)]
end
module.TelekineticPush = function(Character,Target,CameraVector)
local HRP = Character.HumanoidRootPart
local THRP = Target.HumanoidRootPart
local TRagdoll = Target.Ragdoll
if CheckDebounce(Character,Target) == true then
TKPushData['Debounce'][Character] = {Last = tick()}
local Force = Instance.new('LinearVelocity')
TRagdoll.Value += 2
local Force = Instance.new("BodyVelocity")
Force.MaxForce = Vector3.new(30000,math.huge,30000)
Force.P = math.huge
Force.Velocity = Vector3.new(45,0,45) *CameraVector
Force.Velocity += Vector3.new(0,5,0)
Force.Parent = THRP
DebriService:AddItem(Force,.3)
local Animation = Instance.new('Animation')
Animation.AnimationId = 'rbxassetid://'
local Track = Character.Humanoid.Animator:LoadAnimation(Animation)
Track:Play()
print("Script Works")
game.ReplicatedStorage.SoundEvent.OnServerEvent:Connect(function(plr)
print("Fireee")
game.SoundService.Sound:Play()
end)
wait(TKPushData['DebounceTime'])
for _, v in pairs(TKPushData['Victims']) do
if v == Target then
table.remove(TKPushData['Victims'],v)
end
end
end
end
return module
and how do we do that?
Give me a minute, ill just make the code.
Does the player have to press a button for the sound to play?
These are all the parts you need in your workspace.
Server Sided Script
local Rep = game:GetService("ReplicatedStorage")
local SoundReact = Rep:WaitForChild("PlaySoundH")
SoundReact.OnServerEvent:Connect(function(plr, SoundId, Range, Volume)
local Character = plr.Character
if Character then
local HeadInstance = Character:FindFirstChild("Head")
if HeadInstance then
local NewSound = Instance.new("Sound",HeadInstance)
NewSound.SoundId = SoundId
NewSound.RollOffMaxDistance = Range
NewSound.Volume = Volume
NewSound:Play()
NewSound.Ended:Connect(function()
NewSound:Destroy()
end)
end
end
end)
Client Side script: That works with the button E
local Rep = game:WaitForChild("ReplicatedStorage")
local SoundPlay = Rep:WaitForChild("PlaySoundH")
local ContextAction = game:GetService("ContextActionService")
function PlaySound(Inputname,InputState,InputObject)
if Inputname == "PlaySound" and InputState == Enum.UserInputState.Begin then
SoundPlay:FireServer("rbxassetid://9114163343", 100, 1) --- First Parm is the sound Id, Second one is the range, and third is the volume
end
end
ContextAction:BindAction("PlaySound",PlaySound,false,Enum.KeyCode.E)
He wants a push system where you press E to push the player, and the sound plays in the first post.
@Aikious why did you start a second post about this same topic? How to adjust the distance of a sound with "rolloffmaxdistance"??
Change the client-side script, to work as intended in your game.
Hmm, how irritating… Anyways this script should work, all he as to do is set up user-input into the client-sided script so It will play every time a player presses E.
I expressed myself badly on the first subject, I want to delete it but I can’t find how, sorry.
Oh it works ! Thank you so much !