So basically i was working on a tool that stuns players. Most of the script is working with not problem but i still could not figure out how to blur player’s vision when touched the tool.
Well i tried putting it in local script but that would limit other things so i added one server script and remote event. Didn’t work out either. So i went looking on devforum and developer hub and i didn’t find the solution.
So i gave up and posted this topic…
I don’t want to sound like i want the entire scripts, because i completely deleted the code.
So i just want a help how would i make it working.
I am not good at english so you may not understand what i want to achieve
When other player touches the tool it will stun the player and blur his vision (for example player that is holding the tool will smack him and stun him lol)
@Ligij That’s the starting of the solution.
You should fire the RemoteEvent in the script, when a Touch event is fired (you should make sure that the tool has touched a player that has a humnaoid in it).
Let me know if you need help with that^
Server script can only fire one specified cliend or all clients, how would i define player who touched the part, it would not work if player was not included
first i have to get player from touch event
but how
game.Workspace.PartTest.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit)
blurevent:FireServer(player, true)
end
end)
Change the beginning of the script (“game.Workspace.PartTest”) to your part.
Here is the outline of how I would do it. It is quite janky but it will work
(This will not work if you just past it. you have to write the code yourself, but I gave you everything you needed to put together the script)
--Local Script
get tweenservice
get local player
get mouse
get lighting.blur
get remote event
define debounce
mouse click event
if not debounce
set debounce to true
fire server your mouse.Target
wait 1 second
set debounce to false
remote event on client event
play tween for blur that sets size to 24
wait however long you want
play tween for blur that sets size to 0
--server script
get remote event
define debounce (table)
remote event on server event (params player, mouse target)
define targetplayer = game.Players:GetPlayerFromCharacter(target:FindFirstAncestorWhichIsA(model))
if not debounce[player] and targetplayer then
debounce[player] = true
stun the targetplayer using ragdoll idk
remote event:FireClient(targetplayer)
wait(.9) -- gotta be a bit less just in case of overlap
debounce[player] = false