so i have been making a script so that i can’t jump and if i press space you get kicked but i want that if you get kicked you will see a message in the chat that a user who got kicked by jumping has gotten kicked but it doesn’t work this is a classic script i have to put it in serverscriptservice for it to work
– ServerScriptService > JumpLockScript
local Players = game:GetService(“Players”)
local DataStoreService = game:GetService(“DataStoreService”)
local JumpPowerDataStore = DataStoreService:GetDataStore(“JumpPowerDataStore”) – Create a DataStore
– Set the default jump power for new players
local DEFAULT_JUMP_POWER = 0
– Function to set the jump power for a player
local function setJumpPower(player, jumpPower)
local success, err = pcall(function()
JumpPowerDataStore:SetAsync(tostring(player.UserId), jumpPower)
end)
if not success then
warn("Failed to set jump power for " … player.Name … ": " … err)
end
end
– Function to get the jump power for a player
local function getJumpPower(player)
local success, jumpPower = pcall(function()
return JumpPowerDataStore:GetAsync(tostring(player.UserId))
end)
if success then
return jumpPower
else
return DEFAULT_JUMP_POWER
end
end
– Function to check if a player is inside the disabled region
local function isPlayerInDisabledRegion(player)
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild(“HumanoidRootPart”)
if humanoidRootPart then
local playerPosition = humanoidRootPart.Position
– Define the region where jumping is disabled
local minRegion = Vector3.new(-10, 0, -10)
local maxRegion = Vector3.new(10, 5, 10)
if playerPosition.x >= minRegion.x and playerPosition.x <= maxRegion.x
and playerPosition.y >= minRegion.y and playerPosition.y <= maxRegion.y
and playerPosition.z >= minRegion.z and playerPosition.z <= maxRegion.z then
return true
end
end
end
return false
end
– Function to kick a player for jumping
local function kickForJump(player)
player:Kick(“No jumping allowed in this area. Rejoin to continue.”)
end
– Set the initial jump power and control jumping for all players
Players.PlayerAdded:Connect(function(player)
local jumpPower = getJumpPower(player)
player.CharacterAdded:Connect(function(character)
wait(1) – Wait for the character to fully load
local humanoid = character:WaitForChild(“Humanoid”)
-- Disable jumping
humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
-- Set jump power
humanoid.JumpPower = jumpPower
-- Hook into the JumpRequest event to detect jumping attempts
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if isPlayerInDisabledRegion(player) then
kickForJump(player)
local message = "Game: " .. player.Name .. " has tried to jump but got kicked."
player:WaitForChild("PlayerGui"):SetCore("ChatMakeSystemMessage", {
Text = message;
Color = Color3.new(1, 0, 0);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size24;
})
end
end)
end)
end)
– Save the jump power when a player leaves
Players.PlayerRemoving:Connect(function(player)
local jumpPower = player.Character and player.Character:FindFirstChild(“Humanoid”) and player.Character.Humanoid.JumpPower or DEFAULT_JUMP_POWER
setJumpPower(player, jumpPower)
end)
and another script this is a local script that i have to put into starterplayerscripts so the player can get kicked by jumping and it has to send the message but that doesn’t work
– StarterPlayerScripts > JumpLockLocalScript
local StarterGui = game:GetService(“StarterGui”)
game.Players.PlayerRemoving:Connect(function(player)
local reason = player:Kick()
if reason == “No jumping allowed in this area. Rejoin to continue.” then
local message = “Game: " … player.Name … " has tried to jump but got kicked.”
StarterGui:SetCore(“ChatMakeSystemMessage”, {
Text = message;
Color = Color3.new(1, 0, 0);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size24;
})
end
end)