Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Issue with concatenate userdata with string, how do I fix this?

To sum it up, starting script checks if player is exploiting, fires event, event kicks player with reason, and what exploit was used.

Starting Script:

local player = game.Players.LocalPlayer
local humanoid = script.Parent.Humanoid
local event = game.ReplicatedStorage.Events.exploitpossible

local exploitType

local check = 0
local tf = false

while wait(1) do
	
	if humanoid.WalkSpeed ~= 16 then
			
		if tf == false then
			exploitType = "speed"
			exploitType2 = "speed"
			event:FireServer(exploitType, player)
			check = check +1
			print(exploitType, check)
			wait(5)
			tf = false
		end
	end
	
	
	if humanoid.JumpPower ~= 50 then
			
		if tf == false then
			tf = true
			exploitType = "jump"
			exploitType2 = "jump power"
			event:FireServer(exploitType, player)
			check = check +1
			print(exploitType, check)
			wait(5)
			tf = false
		end
	end
	
	if humanoid.parent.HumanoidRootPart.CanCollide == false then
		
		if tf == false then
			tf = true
			exploitType = "noclip"
			exploitType2 = "noclip"
			event:FireServer(exploitType, player)
			check = check +1
			print(exploitType, check)
			wait(5)
			tf = false
		end
	end
	
	if check == 3 then
		
		game.ReplicatedStorage.Events.Kick:FireServer(exploitType, player)
		
		break
	end
end

Kicking Script:

game.Players.PlayerAdded:Connect(function(player)
game.ReplicatedStorage.Events.Kick.OnServerEvent:Connect(function(exploitType)
	
	player.Info.kicks.Value = player.Info.kicks.Value +1
	
	player:Kick("You have reached 3 exploit warnings. If you continue to exploit, you will be banned. Reason for exploiting:"..exploitType..".")
	
end)	
end)

1 answer

✓ Accepted answer

This is an issue with your RemoteEvent parameters. It's a quick solve however! The first parameter supplied with the .OnServerEvent signal, is actually the Client that fired the Event—this is imposed. All trailing parameters are the arguments you supplied.

As we receive the Client that fired, we loose the need to pass the local Player Object:

---< LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage:WaitForChild("Events")
local KickEvent = Events:WaitForChild("KickEvent")

KickEvent:FireServer(ExploitType)

---< ServerScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage:WaitForChild("Events")
local KickEvent = Events:WaitForChild("KickEvent")

KickEvent.OnServerEvent:Connect(function(Player, ExploitType)
	Player:Kick("You were kicked for "..ExploitType)
end)

Userdata is another word for Object, in this case, it was letting you know you were trying to put an Object in a string literal.

This discussion is preserved as it was. New answers, comments, and votes are closed.